Completed
Push — v3.0 ( 23635d...e28df5 )
by Samir
23s
created
astpp/application/modules/accounts/views/view_customer_dids.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -104,10 +104,10 @@
 block discarded – undo
104 104
                                 <label for="Country" class="col-md-3 no-padding">Country : </label>
105 105
                                 <div class="col-md-8 no-padding sel_drop">
106 106
                                  <?php
107
-                                $country_arr = array("id" => "country_id", "name" => "country_id", "class" => "country_id");
108
-                                $country = form_dropdown($country_arr, $this->db_model->build_dropdown("id,country", "countrycode", "", ""), $country_id);
109
-                                echo $country;
110
-                                ?>
107
+								$country_arr = array("id" => "country_id", "name" => "country_id", "class" => "country_id");
108
+								$country = form_dropdown($country_arr, $this->db_model->build_dropdown("id,country", "countrycode", "", ""), $country_id);
109
+								echo $country;
110
+								?>
111 111
                                 </div>
112 112
                             </div>
113 113
                             <div class="col-md-4">
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/accounts/models/accounts_model.php 1 patch
Indentation   +674 added lines, -674 removed lines patch added patch discarded remove patch
@@ -24,24 +24,24 @@  discard block
 block discarded – undo
24 24
 
25 25
 class Accounts_model extends CI_Model {
26 26
 
27
-    function Accounts_model() {
28
-        parent::__construct();
29
-    }
27
+	function Accounts_model() {
28
+		parent::__construct();
29
+	}
30 30
 
31
-    function add_account($accountinfo) {
31
+	function add_account($accountinfo) {
32 32
 	
33
-        $account_data = $this->session->userdata("accountinfo");
34
-        $accountinfo['reseller_id'] = ($account_data['type'] == 1 ) ? $account_data['id'] : 0;
35
-        $accountinfo['maxchannels'] = ($accountinfo['type'] == 1 || $account_data['type'] == 2 || $account_data['type'] == -1 ) ? "0" : $accountinfo['maxchannels'];
36
-        unset($accountinfo['action']);
37
-        $sip_flag = isset($accountinfo['sip_device_flag']) ? 1 : 0;
38
-        $opensip_flag = isset($accountinfo['opensips_device_flag']) ? 1 : 0;
39
-        unset($accountinfo['sip_device_flag'],$accountinfo['opensips_device_flag'],$accountinfo['tax_id']);
40
-
41
-        /*         * ******************************** */
42
-        $accountinfo['creation'] = gmdate('Y-m-d H:i:s');
43
-        $accountinfo['expiry'] = gmdate('Y-m-d H:i:s', strtotime('+20 years'));
44
-        /*if(isset($accountinfo['is_recording'])){
33
+		$account_data = $this->session->userdata("accountinfo");
34
+		$accountinfo['reseller_id'] = ($account_data['type'] == 1 ) ? $account_data['id'] : 0;
35
+		$accountinfo['maxchannels'] = ($accountinfo['type'] == 1 || $account_data['type'] == 2 || $account_data['type'] == -1 ) ? "0" : $accountinfo['maxchannels'];
36
+		unset($accountinfo['action']);
37
+		$sip_flag = isset($accountinfo['sip_device_flag']) ? 1 : 0;
38
+		$opensip_flag = isset($accountinfo['opensips_device_flag']) ? 1 : 0;
39
+		unset($accountinfo['sip_device_flag'],$accountinfo['opensips_device_flag'],$accountinfo['tax_id']);
40
+
41
+		/*         * ******************************** */
42
+		$accountinfo['creation'] = gmdate('Y-m-d H:i:s');
43
+		$accountinfo['expiry'] = gmdate('Y-m-d H:i:s', strtotime('+20 years'));
44
+		/*if(isset($accountinfo['is_recording'])){
45 45
 	  $accountinfo['is_recording']=0;
46 46
         }else{
47 47
 	  $accountinfo['is_recording']=1;
@@ -51,401 +51,401 @@  discard block
 block discarded – undo
51 51
         }else{
52 52
 	  $accountinfo['allow_ip_management']=1;
53 53
         }*/
54
-        if(isset($accountinfo['local_call'])){
54
+		if(isset($accountinfo['local_call'])){
55 55
 	  $accountinfo['local_call']=0;
56
-        }else{
56
+		}else{
57 57
 	  $accountinfo['local_call']=1;
58
-        }
59
-        if ($accountinfo['type'] == 1){
60
-        $invoice_config = $accountinfo['invoice_config_flag'];
58
+		}
59
+		if ($accountinfo['type'] == 1){
60
+		$invoice_config = $accountinfo['invoice_config_flag'];
61 61
 		}else{
62 62
 		$invoice_config = "";		
63 63
 		}
64 64
 		unset($accountinfo['invoice_config_flag']);
65
-        $result = $this->db->insert('accounts', $accountinfo);
66
-        $last_id = $this->db->insert_id();
67
-                /**
65
+		$result = $this->db->insert('accounts', $accountinfo);
66
+		$last_id = $this->db->insert_id();
67
+				/**
68 68
           ASTPP  3.0 
69 69
           For Invoice Configuration
70
-         * */ 
71
-         if ($accountinfo['type'] == 1 && isset($invoice_config) && $invoice_config == "0") {
72
-                if ($accountinfo['country_id'] == NULL) {
73
-                    $accountinfo['country_id'] = "";
74
-                } else {
75
-                    $data = $this->db_model->getSelect("country", "countrycode", array("id" => $accountinfo['country_id']));
76
-                    $data = $data->result_array();
77
-                    $country_name = $data[0];
78
-                }
79
-                if ($accountinfo['postal_code'] == NULL) {
80
-                    $accountinfo['postal_code'] = "";
81
-                }
82
-
83
-                $invoice_config = array('accountid' => $last_id, 'company_name' => $accountinfo['company_name'], 'address' => $accountinfo['address_1'], 'city' => $accountinfo['city'], 'province' => $accountinfo['province'], 'country' => $country_name['country'], 'zipcode' => $accountinfo['postal_code'], 'telephone' => $accountinfo['telephone_1'], 'emailaddress' => $accountinfo['email']);
84
-                $this->db->where('account_id', $accountinfo['id']);
85
-                $this->db->insert('invoice_conf', $invoice_config);
86
-            }
87
-        if ($sip_flag == '1') {
88
-            $this->db->select('id');
89
-            $this->db->where('name','default');
90
-            $sipprofile_result=(array)$this->db->get('sip_profiles')->first_row();
91
-            $free_switch_array = array('fs_username' => $accountinfo['number'],
92
-                'fs_password' => $this->common->decode($accountinfo['password']),
93
-                'context' => 'default',
94
-                'effective_caller_id_name' => $accountinfo['number'],
95
-                'effective_caller_id_number' => $accountinfo['number'],
96
-                'sip_profile_id' => $sipprofile_result['id'],
97
-                'pricelist_id' => $accountinfo['pricelist_id'],
98
-                'accountcode' => $last_id,
99
-                'status' => $accountinfo['status']);
100
-            $this->load->model('freeswitch/freeswitch_model');
101
-            $this->freeswitch_model->add_freeswith($free_switch_array);
102
-        }
103
-        if ($opensip_flag == 1) {
104
-            $opensips_array = array('username' => $accountinfo['number'],
105
-                'domain' => common_model::$global_config['system_config']['opensips_domain'],
106
-                'password' => $accountinfo['password'],
107
-                'accountcode' => $accountinfo['number'],
108
-                'pricelist_id' => $accountinfo['pricelist_id']);
109
-            $this->load->model('opensips/opensips_model');
110
-            $this->opensips_model->add_opensipsdevices($opensips_array);
111
-        }
112
-        $accountinfo['confirm'] =  base_url();
113
-        if($accountinfo['id'] == ""){
114
-        $accountinfo['id'] = $last_id;
70
+				 * */ 
71
+		 if ($accountinfo['type'] == 1 && isset($invoice_config) && $invoice_config == "0") {
72
+				if ($accountinfo['country_id'] == NULL) {
73
+					$accountinfo['country_id'] = "";
74
+				} else {
75
+					$data = $this->db_model->getSelect("country", "countrycode", array("id" => $accountinfo['country_id']));
76
+					$data = $data->result_array();
77
+					$country_name = $data[0];
78
+				}
79
+				if ($accountinfo['postal_code'] == NULL) {
80
+					$accountinfo['postal_code'] = "";
81
+				}
82
+
83
+				$invoice_config = array('accountid' => $last_id, 'company_name' => $accountinfo['company_name'], 'address' => $accountinfo['address_1'], 'city' => $accountinfo['city'], 'province' => $accountinfo['province'], 'country' => $country_name['country'], 'zipcode' => $accountinfo['postal_code'], 'telephone' => $accountinfo['telephone_1'], 'emailaddress' => $accountinfo['email']);
84
+				$this->db->where('account_id', $accountinfo['id']);
85
+				$this->db->insert('invoice_conf', $invoice_config);
86
+			}
87
+		if ($sip_flag == '1') {
88
+			$this->db->select('id');
89
+			$this->db->where('name','default');
90
+			$sipprofile_result=(array)$this->db->get('sip_profiles')->first_row();
91
+			$free_switch_array = array('fs_username' => $accountinfo['number'],
92
+				'fs_password' => $this->common->decode($accountinfo['password']),
93
+				'context' => 'default',
94
+				'effective_caller_id_name' => $accountinfo['number'],
95
+				'effective_caller_id_number' => $accountinfo['number'],
96
+				'sip_profile_id' => $sipprofile_result['id'],
97
+				'pricelist_id' => $accountinfo['pricelist_id'],
98
+				'accountcode' => $last_id,
99
+				'status' => $accountinfo['status']);
100
+			$this->load->model('freeswitch/freeswitch_model');
101
+			$this->freeswitch_model->add_freeswith($free_switch_array);
102
+		}
103
+		if ($opensip_flag == 1) {
104
+			$opensips_array = array('username' => $accountinfo['number'],
105
+				'domain' => common_model::$global_config['system_config']['opensips_domain'],
106
+				'password' => $accountinfo['password'],
107
+				'accountcode' => $accountinfo['number'],
108
+				'pricelist_id' => $accountinfo['pricelist_id']);
109
+			$this->load->model('opensips/opensips_model');
110
+			$this->opensips_model->add_opensipsdevices($opensips_array);
111
+		}
112
+		$accountinfo['confirm'] =  base_url();
113
+		if($accountinfo['id'] == ""){
114
+		$accountinfo['id'] = $last_id;
115 115
 		}
116
-        $accountinfo['password'] = $this->common->decode($accountinfo['password']);    
116
+		$accountinfo['password'] = $this->common->decode($accountinfo['password']);    
117 117
 
118
-        $this->common->mail_to_users('email_add_user', $accountinfo);
119
-        return $last_id;
120
-    }
118
+		$this->common->mail_to_users('email_add_user', $accountinfo);
119
+		return $last_id;
120
+	}
121 121
 
122
-    /**
122
+	/**
123 123
       ASTPP  3.0 
124 124
       Reseller Batch Update
125
-     * */
126
-    function reseller_rates_batch_update($update_array) {
127
-        unset($update_array['action']);
128
-        $update_array['type'] = 1;
129
-        $date = gmdate("Y-m-d h:i:s");
130
-        $this->db_model->build_search('reseller_list_search');
131
-        if ($update_array['type'] == 1) {
132
-            $this->db_model->build_batch_update_array($update_array);
133
-            $login_type = $this->session->userdata('logintype');
134
-            $reseller_info = $this->session->userdata['accountinfo'];
135
-            if ($reseller_info['type'] == 1) {
136
-                $this->db->where('reseller_id', $reseller_info['id']);
137
-            } else {
138
-                $this->db->where('reseller_id', '0');
139
-            }
140
-            $this->db->where('type', '1');
141
-            $this->db->update("accounts");
142
-            $this->db_model->build_search('reseller_list_search');
143
-            if (isset($update_array['balance']['balance']) && $update_array['balance']['balance'] != '') {
144
-                $search_flag = $this->db_model->build_search('reseller_list_search');
145
-                $account_data = $this->session->userdata("accountinfo");
146
-                if ($account_data['type'] == 1) {
147
-                    $where = array('type' => 1, "balance" => $update_array['balance']['balance'], "reseller_id" => $account_data['id'], 'deleted' => '0', 'status' => '0');
148
-                } else {
149
-                    $where = array('type' => 1, "balance" => $update_array['balance']['balance'], 'deleted' => '0', 'status' => '0');
150
-                }
151
-
152
-                $this->db_model->build_search('reseller_list_search');
153
-                $query_pricelist = $this->db_model->getSelect("id,reseller_id,balance", "accounts", $where);
154
-                if ($query_pricelist->num_rows > 0) {
155
-                    $description = '';
156
-                    if ($update_array['balance']['operator'] == '2') {
157
-                        $description .="Reseller update set balance by admin";
158
-                    }
159
-                    if ($update_array['balance']['operator'] == '3') {
160
-                        $description .="Reseller update increase balance by admin";
161
-                    }
162
-                    if ($update_array['balance']['operator'] == '4') {
163
-                        $description .="Reseller update descrise balance by admin";
164
-                    }
165
-                    foreach ($query_pricelist->result_array() as $key => $reseller_payment) {
166
-                        if (!empty($reseller_payment['reseller_id']) && $reseller_payment['reseller_id'] != '') {
167
-                            $payment_by = $reseller_payment['reseller_id'];
168
-                        } else {
169
-                            $payment_by = '-1';
170
-                        }
171
-                        $insert_arr = array("accountid" => $reseller_payment['id'],
172
-                            "credit" => $update_array['balance']['balance'],
173
-                            'payment_mode' => 0,
174
-                            'type' => "SYSTEM",
175
-                            "notes" => $description,
176
-                            "payment_date" => $date,
177
-                            'payment_by' => $payment_by,
178
-                            'reseller_id' => $reseller_payment['reseller_id'],
179
-                        );
180
-                        $this->db->insert("payments", $insert_arr);
181
-                    }
182
-                }
183
-            }
184
-        }
125
+	 * */
126
+	function reseller_rates_batch_update($update_array) {
127
+		unset($update_array['action']);
128
+		$update_array['type'] = 1;
129
+		$date = gmdate("Y-m-d h:i:s");
130
+		$this->db_model->build_search('reseller_list_search');
131
+		if ($update_array['type'] == 1) {
132
+			$this->db_model->build_batch_update_array($update_array);
133
+			$login_type = $this->session->userdata('logintype');
134
+			$reseller_info = $this->session->userdata['accountinfo'];
135
+			if ($reseller_info['type'] == 1) {
136
+				$this->db->where('reseller_id', $reseller_info['id']);
137
+			} else {
138
+				$this->db->where('reseller_id', '0');
139
+			}
140
+			$this->db->where('type', '1');
141
+			$this->db->update("accounts");
142
+			$this->db_model->build_search('reseller_list_search');
143
+			if (isset($update_array['balance']['balance']) && $update_array['balance']['balance'] != '') {
144
+				$search_flag = $this->db_model->build_search('reseller_list_search');
145
+				$account_data = $this->session->userdata("accountinfo");
146
+				if ($account_data['type'] == 1) {
147
+					$where = array('type' => 1, "balance" => $update_array['balance']['balance'], "reseller_id" => $account_data['id'], 'deleted' => '0', 'status' => '0');
148
+				} else {
149
+					$where = array('type' => 1, "balance" => $update_array['balance']['balance'], 'deleted' => '0', 'status' => '0');
150
+				}
151
+
152
+				$this->db_model->build_search('reseller_list_search');
153
+				$query_pricelist = $this->db_model->getSelect("id,reseller_id,balance", "accounts", $where);
154
+				if ($query_pricelist->num_rows > 0) {
155
+					$description = '';
156
+					if ($update_array['balance']['operator'] == '2') {
157
+						$description .="Reseller update set balance by admin";
158
+					}
159
+					if ($update_array['balance']['operator'] == '3') {
160
+						$description .="Reseller update increase balance by admin";
161
+					}
162
+					if ($update_array['balance']['operator'] == '4') {
163
+						$description .="Reseller update descrise balance by admin";
164
+					}
165
+					foreach ($query_pricelist->result_array() as $key => $reseller_payment) {
166
+						if (!empty($reseller_payment['reseller_id']) && $reseller_payment['reseller_id'] != '') {
167
+							$payment_by = $reseller_payment['reseller_id'];
168
+						} else {
169
+							$payment_by = '-1';
170
+						}
171
+						$insert_arr = array("accountid" => $reseller_payment['id'],
172
+							"credit" => $update_array['balance']['balance'],
173
+							'payment_mode' => 0,
174
+							'type' => "SYSTEM",
175
+							"notes" => $description,
176
+							"payment_date" => $date,
177
+							'payment_by' => $payment_by,
178
+							'reseller_id' => $reseller_payment['reseller_id'],
179
+						);
180
+						$this->db->insert("payments", $insert_arr);
181
+					}
182
+				}
183
+			}
184
+		}
185 185
 
186
-        return true;
187
-    }
188
-    /**
186
+		return true;
187
+	}
188
+	/**
189 189
       ASTPP  3.0 
190 190
       Customer Batch Update
191
-     * */
192
-    function customer_rates_batch_update($update_array) {
193
-
194
-        unset($update_array['action']);
195
-        $date = gmdate("Y-m-d h:i:s");
196
-        $this->db_model->build_search('customer_list_search');
197
-        $reseller_info = $this->session->userdata['accountinfo'];
198
-        if ($reseller_info['type'] == 1) {
199
-            $this->db->where('reseller_id', $reseller_info['id']);
200
-        } else {
201
-            $this->db->where('reseller_id', '0');
202
-        }
203
-        $this->db_model->build_search('customer_list_search');
204
-        $this->db->where('type !=', '1');
205
-        $this->db_model->build_batch_update_array($update_array);
206
-        $this->db->update("accounts");
207
-        if (isset($update_array['balance']['balance']) && $update_array['balance']['balance'] != '') {
208
-            $account_data = $this->session->userdata("accountinfo");
209
-
210
-            if ($account_data['type'] == 1) {
211
-                $where = array('type' => 1, "reseller_id" => $account_data['id'], 'deleted' => '0', 'status' => '0');
212
-            } else {
213
-                $where = array('type !=' => '-1', "balance" => $update_array['balance']['balance'], 'deleted' => '0', 'status' => '0');
214
-            }
215
-
216
-            $this->db_model->build_search('customer_list_search');
217
-            $query_pricelist = $this->db_model->getSelect("id,reseller_id,balance", "accounts", $where);
218
-            if ($query_pricelist->num_rows > 0) {
219
-                $description = '';
220
-                if ($update_array['balance']['operator'] == '2') {
221
-                    $description .="Customer update set balance by admin";
222
-                }
223
-                if ($update_array['balance']['operator'] == '3') {
224
-                    $description .="Customer update increase balance by admin";
225
-                }
226
-                if ($update_array['balance']['operator'] == '4') {
227
-                    $description .="Customer update descrise balance by admin";
228
-                }
229
-                foreach ($query_pricelist->result_array() as $key => $customer_payment) {
230
-                    if (!empty($customer_payment['reseller_id']) && $customer_payment['reseller_id'] != '0') {
231
-                        $payment_by = $customer_payment['reseller_id'];
232
-                    } else {
233
-                        $payment_by = '-1';
234
-                    }
235
-                    $insert_arr = array("accountid" => $customer_payment['id'],
236
-                        "credit" => $update_array['balance']['balance'],
237
-                        'payment_mode' => 0,
238
-                        'type' => "SYSTEM",
239
-                        "notes" => $description,
240
-                        "payment_date" => $date,
241
-                        'payment_by' => $payment_by,
242
-                        'reseller_id' => $customer_payment['reseller_id'],
243
-                    );
244
-                    $this->db->insert("payments", $insert_arr);
245
-                }
246
-            }
247
-        }
248
-        return true;
249
-    }
250
-
251
-    /*     * ************************************************************************ */
252
-
253
-    function edit_account($accountinfo, $edit_id) {
254
-        unset($accountinfo['action']);
255
-        unset($accountinfo['onoffswitch']);
256
-        $this->db->where('id', $edit_id);
257
-        $result = $this->db->update('accounts', $accountinfo);
258
-        return true;
259
-    }
260
-
261
-    function bulk_insert_accounts($add_array) {
262
-        $logintype = $this->session->userdata('logintype');
263
-        $creation_limit = $this->get_max_limit($add_array);
264
-        $count = $add_array['count'];
265
-        $pin_flag = $add_array['pin'];
191
+	 * */
192
+	function customer_rates_batch_update($update_array) {
193
+
194
+		unset($update_array['action']);
195
+		$date = gmdate("Y-m-d h:i:s");
196
+		$this->db_model->build_search('customer_list_search');
197
+		$reseller_info = $this->session->userdata['accountinfo'];
198
+		if ($reseller_info['type'] == 1) {
199
+			$this->db->where('reseller_id', $reseller_info['id']);
200
+		} else {
201
+			$this->db->where('reseller_id', '0');
202
+		}
203
+		$this->db_model->build_search('customer_list_search');
204
+		$this->db->where('type !=', '1');
205
+		$this->db_model->build_batch_update_array($update_array);
206
+		$this->db->update("accounts");
207
+		if (isset($update_array['balance']['balance']) && $update_array['balance']['balance'] != '') {
208
+			$account_data = $this->session->userdata("accountinfo");
209
+
210
+			if ($account_data['type'] == 1) {
211
+				$where = array('type' => 1, "reseller_id" => $account_data['id'], 'deleted' => '0', 'status' => '0');
212
+			} else {
213
+				$where = array('type !=' => '-1', "balance" => $update_array['balance']['balance'], 'deleted' => '0', 'status' => '0');
214
+			}
215
+
216
+			$this->db_model->build_search('customer_list_search');
217
+			$query_pricelist = $this->db_model->getSelect("id,reseller_id,balance", "accounts", $where);
218
+			if ($query_pricelist->num_rows > 0) {
219
+				$description = '';
220
+				if ($update_array['balance']['operator'] == '2') {
221
+					$description .="Customer update set balance by admin";
222
+				}
223
+				if ($update_array['balance']['operator'] == '3') {
224
+					$description .="Customer update increase balance by admin";
225
+				}
226
+				if ($update_array['balance']['operator'] == '4') {
227
+					$description .="Customer update descrise balance by admin";
228
+				}
229
+				foreach ($query_pricelist->result_array() as $key => $customer_payment) {
230
+					if (!empty($customer_payment['reseller_id']) && $customer_payment['reseller_id'] != '0') {
231
+						$payment_by = $customer_payment['reseller_id'];
232
+					} else {
233
+						$payment_by = '-1';
234
+					}
235
+					$insert_arr = array("accountid" => $customer_payment['id'],
236
+						"credit" => $update_array['balance']['balance'],
237
+						'payment_mode' => 0,
238
+						'type' => "SYSTEM",
239
+						"notes" => $description,
240
+						"payment_date" => $date,
241
+						'payment_by' => $payment_by,
242
+						'reseller_id' => $customer_payment['reseller_id'],
243
+					);
244
+					$this->db->insert("payments", $insert_arr);
245
+				}
246
+			}
247
+		}
248
+		return true;
249
+	}
250
+
251
+	/*     * ************************************************************************ */
252
+
253
+	function edit_account($accountinfo, $edit_id) {
254
+		unset($accountinfo['action']);
255
+		unset($accountinfo['onoffswitch']);
256
+		$this->db->where('id', $edit_id);
257
+		$result = $this->db->update('accounts', $accountinfo);
258
+		return true;
259
+	}
260
+
261
+	function bulk_insert_accounts($add_array) {
262
+		$logintype = $this->session->userdata('logintype');
263
+		$creation_limit = $this->get_max_limit($add_array);
264
+		$count = $add_array['count'];
265
+		$pin_flag = $add_array['pin'];
266 266
         
267
-        $balance = $add_array['balance'] != '' ? $add_array['balance'] : 0.0000;
268
-        $credit_limit = $add_array['credit_limit'] != '' ? $add_array['credit_limit'] : 0.0000;
269
-        $prefix = $add_array['prefix'];
270
-        $account_length = $add_array['account_length'];
267
+		$balance = $add_array['balance'] != '' ? $add_array['balance'] : 0.0000;
268
+		$credit_limit = $add_array['credit_limit'] != '' ? $add_array['credit_limit'] : 0.0000;
269
+		$prefix = $add_array['prefix'];
270
+		$account_length = $add_array['account_length'];
271 271
         
272
-        $length = strlen($prefix);
273
-        if ($length != 0) {
274
-            $number_length = $account_length - $length;
275
-        } else {
276
-            $number_length = $account_length;
277
-        }
272
+		$length = strlen($prefix);
273
+		if ($length != 0) {
274
+			$number_length = $account_length - $length;
275
+		} else {
276
+			$number_length = $account_length;
277
+		}
278 278
 
279
-        $pricelist_id = $add_array['pricelist_id'] != '' ? $add_array['pricelist_id'] : 0;
280
-        $number = $this->common->find_uniq_rendno_accno($number_length, 'number', 'accounts', $prefix, $count);
281
-        $password = $this->common->find_uniq_rendno_accno($number_length, 'password', 'accounts', '', $count);
282
-        if ($pin_flag) {
283
-            $pin = $this->common->find_uniq_rendno_accno($number_length, 'pin', 'accounts', '', $count);
284
-        }
285
-        $sip_flag = false;
286
-        $opensip_flag=false;
287
-        if (isset($add_array['sip_device_flag']) && common_model::$global_config['system_config']['opensips']== 0) {
288
-            $sip_flag = true;
289
-        }
290
-        if (isset($add_array['opensips_device_flag']) && common_model::$global_config['system_config']['opensips']== 1) {
291
-            $opensip_flag = true;
292
-        }
293
-        unset(
294
-                $add_array['count'],
295
-                $add_array['pin'],
296
-                $add_array['account_length'],
297
-                $add_array['prefix'],
298
-                $add_array['sip_device_flag'],
299
-                $add_array['opensips_device_flag']
300
-        );
301
-        if(isset($add_array['is_recording']) &&  $add_array['is_recording'] != ''){
302
-        $is_recording=1;
303
-        }else{
304
-        $is_recording=0;
305
-        }
306
-        if(isset($add_array['allow_ip_management']) &&  $add_array['allow_ip_management'] != ''){
307
-        $allow_ip_management=1;
308
-        }else{
309
-        $allow_ip_management=0;
310
-        }
311
-        if(isset($add_array['local_call']) &&  $add_array['local_call'] != ''){
312
-        $local_call=1;
313
-        }else{
314
-        $local_call=0;
315
-        }
316
-        if ($sip_flag) {
317
-            $query = $this->db_model->select("*", "sip_profiles", array('status' => "0"), "id", "ASC", '1', '0');
318
-            $sip_id = $query->result_array();
319
-            $sip_profile_id = $sip_id[0]['id'];
320
-            for ($i = 0; $i < $count; $i++) {
321
-                $acc_num = $number[$i];
322
-                $current_password = $password[$i];
323
-                $insert_array = array('number' => $acc_num,
324
-                    'password' => $this->common->encode($current_password),
325
-                    'pricelist_id' => $pricelist_id,
326
-                    'reseller_id' => $add_array['reseller_id'],
327
-                    'status' => 0,
328
-                    'credit_limit' => $credit_limit,
329
-                    'posttoexternal' => $add_array['posttoexternal'],
330
-                    'balance' => $balance,
331
-                    'currency_id' => $add_array['currency_id'],
332
-                    'country_id' => $add_array['country_id'],
333
-                    'timezone_id' => $add_array['timezone_id'],
334
-                    'company_name' => $add_array['company_name'],
335
-                    'first_name' => $acc_num,
336
-                    'type' => 0,
337
-                    'charge_per_min'=>$add_array['charge_per_min'],
338
-                    'validfordays' => $add_array['validfordays'],
339
-                    "creation"=>gmdate("Y-m-d H:i:s"),
340
-                    "maxchannels"=>0,
341
-                    "sweep_id"=>$add_array['sweep_id'],
342
-                    "local_call"=>$local_call,
343
-                     "invoice_day"=>$add_array['invoice_day'],
344
-                    "allow_ip_management"=>$allow_ip_management,
345
-                    "is_recording"=>$is_recording,
346
-                    "expiry" => gmdate('Y-m-d H:i:s', strtotime('+10 years'))
347
-                );
348
-                if ($pin_flag == 1) {
349
-                    $insert_array['pin'] = $pin[$i];
350
-                }
351
-                $this->db->insert('accounts', $insert_array);
352
-                $last_id = $this->db->insert_id();
353
-                $params_array = array('password' => $password[$i],
354
-                    "vm-enabled"=>"true",
355
-                    "vm-password"=>"",
356
-                    "vm-mailto"=>"",
357
-                    "vm-attach-file"=>"true",
358
-                    "vm-keep-local-after-email"=>"true",
359
-                    "vm-email-all-messages"=>"true"
360
-                    );
361
-                $params_array_vars = array('effective_caller_id_name' => $acc_num,
362
-                    'effective_caller_id_number' => $acc_num,
363
-                    'user_context' => 'default');
364
-                $sip_device_array[$i] = array('username' => $acc_num,
365
-                    'sip_profile_id' => $sip_profile_id,
366
-                    'reseller_id' => $add_array['reseller_id'],
367
-                    'accountid' => $last_id,
368
-                    'dir_params' => json_encode($params_array),
369
-                    'dir_vars' => json_encode($params_array_vars),
370
-                    'status' => 0,
371
-                    'creation_date' => gmdate("Y-m-d H:i:s")
372
-                    );
373
-            }
374
-            $this->db->insert_batch('sip_devices', $sip_device_array);
375
-        } else {
376
-            for ($i = 0; $i < $count; $i++) {
377
-                $acc_num = $number[$i];
378
-                $current_password = $password[$i];
379
-                $insert_array[$i] = array('number' => $acc_num,
380
-                    'password' => $this->common->encode($current_password),
381
-                    'pricelist_id' => $pricelist_id,
382
-                    'reseller_id' => $add_array['reseller_id'],
383
-                    'status' => 0,
384
-                    'credit_limit' => $credit_limit,
385
-                    'sweep_id' => 0,
386
-                    'posttoexternal' => $add_array['posttoexternal'],
387
-                    'balance' => $balance,
388
-                    'currency_id' => $add_array['currency_id'],
389
-                    'country_id' => $add_array['country_id'],
390
-                    'timezone_id' => $add_array['timezone_id'],
391
-                    'company_name' => $add_array['company_name'],
392
-                    'invoice_day' => 0,
393
-                    'first_name' => $acc_num,
394
-                    'type' => 0,
395
-                    'validfordays' => $add_array['validfordays'],
396
-                    "creation"=>gmdate("Y-m-d H:i:s"),
397
-                    "is_recording"=>0,
398
-                    "maxchannels"=>0,
399
-                    "sweep_id"=>2,
400
-                    "invoice_day"=>gmdate("d"),
401
-                    "expiry" => gmdate('Y-m-d H:i:s', strtotime('+10 years'))
279
+		$pricelist_id = $add_array['pricelist_id'] != '' ? $add_array['pricelist_id'] : 0;
280
+		$number = $this->common->find_uniq_rendno_accno($number_length, 'number', 'accounts', $prefix, $count);
281
+		$password = $this->common->find_uniq_rendno_accno($number_length, 'password', 'accounts', '', $count);
282
+		if ($pin_flag) {
283
+			$pin = $this->common->find_uniq_rendno_accno($number_length, 'pin', 'accounts', '', $count);
284
+		}
285
+		$sip_flag = false;
286
+		$opensip_flag=false;
287
+		if (isset($add_array['sip_device_flag']) && common_model::$global_config['system_config']['opensips']== 0) {
288
+			$sip_flag = true;
289
+		}
290
+		if (isset($add_array['opensips_device_flag']) && common_model::$global_config['system_config']['opensips']== 1) {
291
+			$opensip_flag = true;
292
+		}
293
+		unset(
294
+				$add_array['count'],
295
+				$add_array['pin'],
296
+				$add_array['account_length'],
297
+				$add_array['prefix'],
298
+				$add_array['sip_device_flag'],
299
+				$add_array['opensips_device_flag']
300
+		);
301
+		if(isset($add_array['is_recording']) &&  $add_array['is_recording'] != ''){
302
+		$is_recording=1;
303
+		}else{
304
+		$is_recording=0;
305
+		}
306
+		if(isset($add_array['allow_ip_management']) &&  $add_array['allow_ip_management'] != ''){
307
+		$allow_ip_management=1;
308
+		}else{
309
+		$allow_ip_management=0;
310
+		}
311
+		if(isset($add_array['local_call']) &&  $add_array['local_call'] != ''){
312
+		$local_call=1;
313
+		}else{
314
+		$local_call=0;
315
+		}
316
+		if ($sip_flag) {
317
+			$query = $this->db_model->select("*", "sip_profiles", array('status' => "0"), "id", "ASC", '1', '0');
318
+			$sip_id = $query->result_array();
319
+			$sip_profile_id = $sip_id[0]['id'];
320
+			for ($i = 0; $i < $count; $i++) {
321
+				$acc_num = $number[$i];
322
+				$current_password = $password[$i];
323
+				$insert_array = array('number' => $acc_num,
324
+					'password' => $this->common->encode($current_password),
325
+					'pricelist_id' => $pricelist_id,
326
+					'reseller_id' => $add_array['reseller_id'],
327
+					'status' => 0,
328
+					'credit_limit' => $credit_limit,
329
+					'posttoexternal' => $add_array['posttoexternal'],
330
+					'balance' => $balance,
331
+					'currency_id' => $add_array['currency_id'],
332
+					'country_id' => $add_array['country_id'],
333
+					'timezone_id' => $add_array['timezone_id'],
334
+					'company_name' => $add_array['company_name'],
335
+					'first_name' => $acc_num,
336
+					'type' => 0,
337
+					'charge_per_min'=>$add_array['charge_per_min'],
338
+					'validfordays' => $add_array['validfordays'],
339
+					"creation"=>gmdate("Y-m-d H:i:s"),
340
+					"maxchannels"=>0,
341
+					"sweep_id"=>$add_array['sweep_id'],
342
+					"local_call"=>$local_call,
343
+					 "invoice_day"=>$add_array['invoice_day'],
344
+					"allow_ip_management"=>$allow_ip_management,
345
+					"is_recording"=>$is_recording,
346
+					"expiry" => gmdate('Y-m-d H:i:s', strtotime('+10 years'))
347
+				);
348
+				if ($pin_flag == 1) {
349
+					$insert_array['pin'] = $pin[$i];
350
+				}
351
+				$this->db->insert('accounts', $insert_array);
352
+				$last_id = $this->db->insert_id();
353
+				$params_array = array('password' => $password[$i],
354
+					"vm-enabled"=>"true",
355
+					"vm-password"=>"",
356
+					"vm-mailto"=>"",
357
+					"vm-attach-file"=>"true",
358
+					"vm-keep-local-after-email"=>"true",
359
+					"vm-email-all-messages"=>"true"
360
+					);
361
+				$params_array_vars = array('effective_caller_id_name' => $acc_num,
362
+					'effective_caller_id_number' => $acc_num,
363
+					'user_context' => 'default');
364
+				$sip_device_array[$i] = array('username' => $acc_num,
365
+					'sip_profile_id' => $sip_profile_id,
366
+					'reseller_id' => $add_array['reseller_id'],
367
+					'accountid' => $last_id,
368
+					'dir_params' => json_encode($params_array),
369
+					'dir_vars' => json_encode($params_array_vars),
370
+					'status' => 0,
371
+					'creation_date' => gmdate("Y-m-d H:i:s")
372
+					);
373
+			}
374
+			$this->db->insert_batch('sip_devices', $sip_device_array);
375
+		} else {
376
+			for ($i = 0; $i < $count; $i++) {
377
+				$acc_num = $number[$i];
378
+				$current_password = $password[$i];
379
+				$insert_array[$i] = array('number' => $acc_num,
380
+					'password' => $this->common->encode($current_password),
381
+					'pricelist_id' => $pricelist_id,
382
+					'reseller_id' => $add_array['reseller_id'],
383
+					'status' => 0,
384
+					'credit_limit' => $credit_limit,
385
+					'sweep_id' => 0,
386
+					'posttoexternal' => $add_array['posttoexternal'],
387
+					'balance' => $balance,
388
+					'currency_id' => $add_array['currency_id'],
389
+					'country_id' => $add_array['country_id'],
390
+					'timezone_id' => $add_array['timezone_id'],
391
+					'company_name' => $add_array['company_name'],
392
+					'invoice_day' => 0,
393
+					'first_name' => $acc_num,
394
+					'type' => 0,
395
+					'validfordays' => $add_array['validfordays'],
396
+					"creation"=>gmdate("Y-m-d H:i:s"),
397
+					"is_recording"=>0,
398
+					"maxchannels"=>0,
399
+					"sweep_id"=>2,
400
+					"invoice_day"=>gmdate("d"),
401
+					"expiry" => gmdate('Y-m-d H:i:s', strtotime('+10 years'))
402 402
                     
403
-                );
404
-                if ($pin_flag == 1) {
405
-                    $insert_array[$i]['pin'] = $pin[$i];
406
-                }
407
-                if ($opensip_flag) {
408
-                    $opensips_domain = common_model::$global_config['system_config']['opensips_domain'];
409
-                    $opensips_array[$i] = array('username' => $acc_num,
410
-                        'domain' => $opensips_domain,
411
-                        'password' => $current_password,
412
-                        'accountcode' => $acc_num,
413
-                        'reseller_id' => $add_array['reseller_id'],
414
-                        "creation_date" => gmdate("Y-m-d H:i:s"),
415
-                        "status"=>0
416
-                        );
417
-                }
418
-            }
419
-            $this->db->insert_batch('accounts', $insert_array);
420
-            if ($opensip_flag == 1) {
421
-                $db_config = Common_model::$global_config['system_config'];
422
-                $opensipdsn = "mysql://" . $db_config['opensips_dbuser'] . ":" . $db_config['opensips_dbpass'] . "@" . $db_config['opensips_dbhost'] . "/" . $db_config['opensips_dbname'] . "?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir=";
423
-                $this->opensips_db = $this->load->database($opensipdsn, true);
424
-                $this->opensips_db->insert_batch("subscriber", $opensips_array);
425
-            }
426
-        }
427
-        return TRUE;
428
-    }
403
+				);
404
+				if ($pin_flag == 1) {
405
+					$insert_array[$i]['pin'] = $pin[$i];
406
+				}
407
+				if ($opensip_flag) {
408
+					$opensips_domain = common_model::$global_config['system_config']['opensips_domain'];
409
+					$opensips_array[$i] = array('username' => $acc_num,
410
+						'domain' => $opensips_domain,
411
+						'password' => $current_password,
412
+						'accountcode' => $acc_num,
413
+						'reseller_id' => $add_array['reseller_id'],
414
+						"creation_date" => gmdate("Y-m-d H:i:s"),
415
+						"status"=>0
416
+						);
417
+				}
418
+			}
419
+			$this->db->insert_batch('accounts', $insert_array);
420
+			if ($opensip_flag == 1) {
421
+				$db_config = Common_model::$global_config['system_config'];
422
+				$opensipdsn = "mysql://" . $db_config['opensips_dbuser'] . ":" . $db_config['opensips_dbpass'] . "@" . $db_config['opensips_dbhost'] . "/" . $db_config['opensips_dbname'] . "?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir=";
423
+				$this->opensips_db = $this->load->database($opensipdsn, true);
424
+				$this->opensips_db->insert_batch("subscriber", $opensips_array);
425
+			}
426
+		}
427
+		return TRUE;
428
+	}
429 429
 
430
-    function get_max_limit($add_array) {
430
+	function get_max_limit($add_array) {
431 431
 		$this->db->where('deleted','0');
432
-        $this->db->where("length(number)", $add_array['account_length']);
433
-        $this->db->like('number', $add_array['prefix'], 'after');
434
-        $this->db->select("count(id) as count");
435
-        $this->db->from('accounts');
436
-        $result = $this->db->get();
437
-        $result = $result->result_array();
438
-        $count = $result[0]['count'];
439
-        $remaining_length = 0;
440
-        $remaining_length = $add_array['account_length'] - strlen($add_array['prefix']);
441
-        $currentlength = pow(10, $remaining_length);
442
-        $currentlength = $currentlength - $count;
443
-        return $currentlength;
444
-    }
445
-    function account_process_payment($data) {
432
+		$this->db->where("length(number)", $add_array['account_length']);
433
+		$this->db->like('number', $add_array['prefix'], 'after');
434
+		$this->db->select("count(id) as count");
435
+		$this->db->from('accounts');
436
+		$result = $this->db->get();
437
+		$result = $result->result_array();
438
+		$count = $result[0]['count'];
439
+		$remaining_length = 0;
440
+		$remaining_length = $add_array['account_length'] - strlen($add_array['prefix']);
441
+		$currentlength = pow(10, $remaining_length);
442
+		$currentlength = $currentlength - $count;
443
+		return $currentlength;
444
+	}
445
+	function account_process_payment($data) {
446 446
 	$data['accountid'] = $data['id'];
447
-        $accountdata=(array)$this->db->get_where('accounts',array("id"=>$data['accountid']))->first_row();
448
-        $accountinfo =$this->session->userdata('accountinfo');
447
+		$accountdata=(array)$this->db->get_where('accounts',array("id"=>$data['accountid']))->first_row();
448
+		$accountinfo =$this->session->userdata('accountinfo');
449 449
 	$data["payment_by"] = $accountdata['reseller_id'] > 0 ? $accountdata['reseller_id'] : '-1';
450 450
 	$data['payment_mode'] = $data['payment_type'];
451 451
 	unset($data['action'],$data['id'],$data['account_currency'],$data['payment_type']);
@@ -477,300 +477,300 @@  discard block
 block discarded – undo
477 477
 		  $accountdata['refill_amount']=$data['credit'];
478 478
 		  $current_id=$accountinfo['type'] ==1 ? $accountinfo['id'] : '0';
479 479
 		  if($accountdata['reseller_id'] == $current_id){
480
-		    $this->common->mail_to_users('voip_account_refilled', $accountdata);
480
+			$this->common->mail_to_users('voip_account_refilled', $accountdata);
481 481
 		  }else{
482
-		    $this->common->mail_to_users('voip_child_account_refilled', $accountdata);
482
+			$this->common->mail_to_users('voip_child_account_refilled', $accountdata);
483 483
 		  }
484 484
 		}
485 485
 	}
486
-    }
486
+	}
487 487
 /****************Completed******************/
488 488
 
489
-    function get_admin_Account_list($flag, $start = 0, $limit = 0, $reseller_id = 0) {
490
-        $this->db_model->build_search('admin_list_search');
491
-        $where = "reseller_id =" . $reseller_id . " AND deleted =0 AND type in (2,4,-1)";
492
-        if ($this->session->userdata('advance_search') == 1) {
493
-            $search = $this->session->userdata('admin_list_search');
494
-            if ($search['type'] == '') {
495
-                $this->db->where($where);
496
-                $this->db_model->build_search('admin_list_search');
497
-            } else {
498
-                $this->db->where('type', $search['type']);
499
-            }
500
-        } else {
501
-            $this->db->where($where);
502
-            $this->db_model->build_search('admin_list_search');
503
-        }
504
-        if ($flag) {
505
-            $this->db->limit($limit, $start);
506
-        }
507
-        if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){
508
-          $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']);
509
-        }else{
510
-            $this->db->order_by('number','desc');
511
-        }
512
-        $result = $this->db->get('accounts');
489
+	function get_admin_Account_list($flag, $start = 0, $limit = 0, $reseller_id = 0) {
490
+		$this->db_model->build_search('admin_list_search');
491
+		$where = "reseller_id =" . $reseller_id . " AND deleted =0 AND type in (2,4,-1)";
492
+		if ($this->session->userdata('advance_search') == 1) {
493
+			$search = $this->session->userdata('admin_list_search');
494
+			if ($search['type'] == '') {
495
+				$this->db->where($where);
496
+				$this->db_model->build_search('admin_list_search');
497
+			} else {
498
+				$this->db->where('type', $search['type']);
499
+			}
500
+		} else {
501
+			$this->db->where($where);
502
+			$this->db_model->build_search('admin_list_search');
503
+		}
504
+		if ($flag) {
505
+			$this->db->limit($limit, $start);
506
+		}
507
+		if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){
508
+		  $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']);
509
+		}else{
510
+			$this->db->order_by('number','desc');
511
+		}
512
+		$result = $this->db->get('accounts');
513 513
 
514
-        if ($flag) {
515
-            return $result;
516
-        } else {
517
-            return $result->num_rows();
518
-        }
519
-    }
520
-
521
-    function get_customer_Account_list($flag, $start = 0, $limit = 0, $export = false) {
522
-        $this->db_model->build_search('customer_list_search');
523
-        $accountinfo = $this->session->userdata("accountinfo");
524
-        $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0;
525
-        $where = array("deleted" => "0", 'reseller_id' => $reseller_id);
526
-        $this->db->select('*');
527
-        $type = "type IN (0,3)";
528
-        $this->db->where($where);
529
-        if ($this->session->userdata('advance_search') == 1) {
530
-            $search = $this->session->userdata('customer_list_search');
531
-            if ($search['type'] != '0' && $search['type'] != '3') {
532
-                $this->db->where($type);
533
-            }
534
-        } else {
535
-            $this->db->where($type);
536
-        }
537
-        if ($flag) {
538
-            if (!$export)
539
-                $this->db->limit($limit, $start);
540
-        }
541
-        if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){
542
-          $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']);
543
-        }else{
544
-            $this->db->order_by('number','desc');
545
-        }
546
-        $result = $this->db->get('accounts');
547
-        if ($flag) {
548
-            return $result;
549
-        } else {
550
-            return $result->num_rows();
551
-        }
552
-    }
514
+		if ($flag) {
515
+			return $result;
516
+		} else {
517
+			return $result->num_rows();
518
+		}
519
+	}
553 520
 
554
-    function get_reseller_Account_list($flag, $start = 0, $limit = 0, $export = false) {
555
-        $this->db_model->build_search('reseller_list_search');
556
-        $where = array('reseller_id' => "0", "deleted" => "0", "type" => "1");
557
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
558
-            $where['reseller_id'] = $this->session->userdata["accountinfo"]['id'];
559
-        }
560
-        if ($flag) {
561
-            $query = $this->db_model->select("*", "accounts", $where, "number", "desc", $limit, $start);
562
-        } else {
563
-            $query = $this->db_model->countQuery("*", "accounts", $where);
564
-        }
565
-        return $query;
566
-    }
567
-
568
-    function get_provider_Account_list($flag, $start = 0, $limit = 0) {
569
-        $this->db_model->build_search('provider_list_search');
570
-        $where = array("deleted" => "0", "type" => "3", 'reseller_id' => 0);
571
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
572
-            $where['reseller_id'] = $this->session->userdata["accountinfo"]['id'];
573
-        }
574
-        if ($flag) {
575
-            $query = $this->db_model->select("*", "accounts", $where, "number", "desc", $limit, $start);
576
-        } else {
577
-            $query = $this->db_model->countQuery("*", "accounts", $where);
578
-        }
579
-        return $query;
580
-    }
581
-
582
-    function remove_customer($id) {
583
-        $this->db->where("id", $id);
584
-        $this->db->where("type <>", "-1");
585
-        $data = array('deleted' => '1');
586
-        $this->db->update("accounts", $data);
587
-        return true;
588
-    }
589
-
590
-    function insert_block($data, $accountid) {
591
-        $data = explode(",", $data);
592
-        $tmp = array();
593
-        if (!empty($data)) {
594
-            foreach ($data as $key => $data_value) {
595
-                $tmp[$key]["accountid"] = $accountid;
596
-                $result = $this->get_pattern_by_id($data_value);
597
-                $tmp[$key]["blocked_patterns"] = $result[0]['pattern'];
598
-                $tmp[$key]["destination"] = $result[0]['comment'];
599
-            }
600
-            return $this->db->insert_batch("block_patterns", $tmp);
601
-        }
602
-    }
603
-
604
-    function get_pattern_by_id($pattern) {
605
-        $patterns = $this->db_model->getSelect("pattern,comment", "routes", array("id" => $pattern));
606
-        $patterns_value = $patterns->result_array();
607
-        return $patterns_value;
608
-    }
609
-
610
-    function get_callerid($account_id) {
611
-        $query = $this->db_model->getSelect("*", "accounts_callerid", array("accountid" => $account_id));
612
-        return $query;
613
-    }
614
-
615
-    function get_account_number($accountid) {
616
-        $query = $this->db_model->getSelect("number", "accounts", array("id" => $accountid));
617
-        if ($query->num_rows() > 0)
618
-            return $query->row_array();
619
-        else
620
-            return false;
621
-    }
622
-
623
-    function add_callerid($data) {
624
-        unset($data['action'],$data['flag']);
625
-        $data['accountid'] = $this->common->get_field_name('id', 'accounts', array('number' => $data['accountid']));
626
-        $this->db->insert('accounts_callerid', $data);
627
-        return true;
628
-    }
629
-
630
-    function edit_callerid($data) {
631
-        unset($data['action']);
632
-        unset($data['flag']);
633
-        $data['accountid'] = $this->common->get_field_name('id', 'accounts', array('number' => $data['accountid']));
634
-        $this->db->where('accountid', $data['accountid']);
635
-        $this->db->update('accounts_callerid', $data);
636
-        return true;
637
-    }
638
-
639
-    /**
640
-     * -------Here we write code for model accounting functions remove_all_account_tax------
641
-     * for remove all account's taxes enteries from database.
642
-     */
643
-    function remove_all_account_tax($account_tax) {
644
-        $this->db->where('accountid', $account_tax);
645
-        $this->db->delete('taxes_to_accounts');
646
-        return true;
647
-    }
648
-
649
-    /**
650
-     * -------Here we write code for model accounting functions add_account_tax------
651
-     * this function use to insert data for add taxes to account.
652
-     */
653
-    function add_account_tax($data) {
654
-        $this->db->insert('taxes_to_accounts', $data);
655
-    }
656
-
657
-    /**
658
-     * -------Here we write code for model accounting functions get_accounttax_by_id------
659
-     * this function use get the account taxes details as per account number
660
-     * @account_id = account id
661
-     */
662
-    function get_accounttax_by_id($account_id) {
663
-        $this->db->where("accountid", trim($account_id));
664
-        $query = $this->db->get("taxes_to_accounts");
665
-        if ($query->num_rows() > 0)
666
-            return $query->result_array();
667
-        else
668
-            return false;
669
-    }
670
-
671
-    /**
672
-     * -------Here we write code for model accounting functions check_account_num------
673
-     * this function write to verify the account number is valid or not.
674
-     * @acc_num = account number
675
-     */
676
-    function check_account_num($acc_num) {
677
-        $this->db->select('accountid');
678
-        $this->db->where("number", $acc_num);
679
-        $query = $this->db->get("accounts");
680
-
681
-        if ($query->num_rows() > 0)
682
-            return $query->row_array();
683
-        else
684
-            return false;
685
-    }
686
-
687
-    function get_account_by_number($id) {
688
-        $this->db->where("id", $id);
689
-        $query = $this->db->get("accounts");
690
-
691
-        if ($query->num_rows() > 0)
692
-            return $query->row_array();
693
-        else
694
-            return false;
695
-    }
696
-
697
-    function get_currency_by_id($currency_id) {
698
-
699
-        $query = $this->db_model->getSelect("*", 'currency', array('id' => $currency_id));
700
-        if ($query->num_rows() > 0)
701
-            return $query->row_array();
702
-        else
703
-            return false;
704
-    }
705
-
706
-
707
-    function update_balance($amount, $accountid, $payment_type) {
708
-        if ($payment_type == 0) {
709
-            $query = 'UPDATE `accounts` SET `balance` = (balance + ' . $amount . ') WHERE `id` = ' . $accountid;
710
-            return $this->db->query($query);
711
-        }if ($payment_type == 1) {
712
-            $query = 'UPDATE `accounts` SET `balance` = (balance - ' . $amount . ') WHERE `id` = ' . $accountid;
713
-            return $this->db->query($query);
714
-        }
715
-    }
521
+	function get_customer_Account_list($flag, $start = 0, $limit = 0, $export = false) {
522
+		$this->db_model->build_search('customer_list_search');
523
+		$accountinfo = $this->session->userdata("accountinfo");
524
+		$reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0;
525
+		$where = array("deleted" => "0", 'reseller_id' => $reseller_id);
526
+		$this->db->select('*');
527
+		$type = "type IN (0,3)";
528
+		$this->db->where($where);
529
+		if ($this->session->userdata('advance_search') == 1) {
530
+			$search = $this->session->userdata('customer_list_search');
531
+			if ($search['type'] != '0' && $search['type'] != '3') {
532
+				$this->db->where($type);
533
+			}
534
+		} else {
535
+			$this->db->where($type);
536
+		}
537
+		if ($flag) {
538
+			if (!$export)
539
+				$this->db->limit($limit, $start);
540
+		}
541
+		if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){
542
+		  $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']);
543
+		}else{
544
+			$this->db->order_by('number','desc');
545
+		}
546
+		$result = $this->db->get('accounts');
547
+		if ($flag) {
548
+			return $result;
549
+		} else {
550
+			return $result->num_rows();
551
+		}
552
+	}
716 553
 
717
-    function account_authentication($where_data, $id) {
718
-        if ($id != "") {
719
-            $this->db->where("id <>", $id);
720
-        }
721
-        $this->db->where($where_data);
722
-        $this->db->from("accounts");
723
-        $query = $this->db->count_all_results();
724
-        return $query;
725
-    }
726
-
727
-    function get_animap($flag, $start, $limit, $id) {
728
-        $where = array('accountid' => $id);
729
-
730
-        if ($flag) {
731
-            $query = $this->db_model->select("*", "ani_map", $where, "number", "DESC", $limit, $start);
732
-        } else {
733
-            $query = $this->db_model->countQuery("*", "ani_map", $where);
734
-        }
735
-        return $query;
736
-    }
737
-
738
-    function add_animap($data) {
739
-        $this->db->insert('ani_map', $data);
740
-        return true;
741
-    }
742
-
743
-    function edit_animap($data, $id) {
744
-        $new_array = array('number' => $data['number'], 'status' => $data['status']);
745
-        $this->db->where('id', $id);
746
-        $this->db->update('ani_map', $new_array);
747
-        return true;
748
-    }
749
-
750
-    function remove_ani_map($id) {
751
-        $this->db->where('id', $id);
752
-        $this->db->delete('ani_map');
753
-        return true;
754
-    }
755
-
756
-    function animap_authentication($where_data, $id) {
757
-        if ($id != "") {
758
-            $this->db->where("id <>", $id);
759
-        }
760
-        $this->db->where($where_data);
761
-        $this->db->from("ani_map");
762
-        $query = $this->db->count_all_results();
763
-        return $query;
764
-    }
765
-    function add_invoice_config($add_array) {
766
-        $result = $this->db->insert('invoice_conf', $add_array);
767
-        return true;
768
-    }
769
-
770
-    function edit_invoice_config($add_array, $edit_id) {
771
-        $this->db->where('id', $edit_id);
772
-        $result = $this->db->update('invoice_conf', $add_array);
773
-        return true;
774
-    }
554
+	function get_reseller_Account_list($flag, $start = 0, $limit = 0, $export = false) {
555
+		$this->db_model->build_search('reseller_list_search');
556
+		$where = array('reseller_id' => "0", "deleted" => "0", "type" => "1");
557
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
558
+			$where['reseller_id'] = $this->session->userdata["accountinfo"]['id'];
559
+		}
560
+		if ($flag) {
561
+			$query = $this->db_model->select("*", "accounts", $where, "number", "desc", $limit, $start);
562
+		} else {
563
+			$query = $this->db_model->countQuery("*", "accounts", $where);
564
+		}
565
+		return $query;
566
+	}
567
+
568
+	function get_provider_Account_list($flag, $start = 0, $limit = 0) {
569
+		$this->db_model->build_search('provider_list_search');
570
+		$where = array("deleted" => "0", "type" => "3", 'reseller_id' => 0);
571
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
572
+			$where['reseller_id'] = $this->session->userdata["accountinfo"]['id'];
573
+		}
574
+		if ($flag) {
575
+			$query = $this->db_model->select("*", "accounts", $where, "number", "desc", $limit, $start);
576
+		} else {
577
+			$query = $this->db_model->countQuery("*", "accounts", $where);
578
+		}
579
+		return $query;
580
+	}
581
+
582
+	function remove_customer($id) {
583
+		$this->db->where("id", $id);
584
+		$this->db->where("type <>", "-1");
585
+		$data = array('deleted' => '1');
586
+		$this->db->update("accounts", $data);
587
+		return true;
588
+	}
589
+
590
+	function insert_block($data, $accountid) {
591
+		$data = explode(",", $data);
592
+		$tmp = array();
593
+		if (!empty($data)) {
594
+			foreach ($data as $key => $data_value) {
595
+				$tmp[$key]["accountid"] = $accountid;
596
+				$result = $this->get_pattern_by_id($data_value);
597
+				$tmp[$key]["blocked_patterns"] = $result[0]['pattern'];
598
+				$tmp[$key]["destination"] = $result[0]['comment'];
599
+			}
600
+			return $this->db->insert_batch("block_patterns", $tmp);
601
+		}
602
+	}
603
+
604
+	function get_pattern_by_id($pattern) {
605
+		$patterns = $this->db_model->getSelect("pattern,comment", "routes", array("id" => $pattern));
606
+		$patterns_value = $patterns->result_array();
607
+		return $patterns_value;
608
+	}
609
+
610
+	function get_callerid($account_id) {
611
+		$query = $this->db_model->getSelect("*", "accounts_callerid", array("accountid" => $account_id));
612
+		return $query;
613
+	}
614
+
615
+	function get_account_number($accountid) {
616
+		$query = $this->db_model->getSelect("number", "accounts", array("id" => $accountid));
617
+		if ($query->num_rows() > 0)
618
+			return $query->row_array();
619
+		else
620
+			return false;
621
+	}
622
+
623
+	function add_callerid($data) {
624
+		unset($data['action'],$data['flag']);
625
+		$data['accountid'] = $this->common->get_field_name('id', 'accounts', array('number' => $data['accountid']));
626
+		$this->db->insert('accounts_callerid', $data);
627
+		return true;
628
+	}
629
+
630
+	function edit_callerid($data) {
631
+		unset($data['action']);
632
+		unset($data['flag']);
633
+		$data['accountid'] = $this->common->get_field_name('id', 'accounts', array('number' => $data['accountid']));
634
+		$this->db->where('accountid', $data['accountid']);
635
+		$this->db->update('accounts_callerid', $data);
636
+		return true;
637
+	}
638
+
639
+	/**
640
+	 * -------Here we write code for model accounting functions remove_all_account_tax------
641
+	 * for remove all account's taxes enteries from database.
642
+	 */
643
+	function remove_all_account_tax($account_tax) {
644
+		$this->db->where('accountid', $account_tax);
645
+		$this->db->delete('taxes_to_accounts');
646
+		return true;
647
+	}
648
+
649
+	/**
650
+	 * -------Here we write code for model accounting functions add_account_tax------
651
+	 * this function use to insert data for add taxes to account.
652
+	 */
653
+	function add_account_tax($data) {
654
+		$this->db->insert('taxes_to_accounts', $data);
655
+	}
656
+
657
+	/**
658
+	 * -------Here we write code for model accounting functions get_accounttax_by_id------
659
+	 * this function use get the account taxes details as per account number
660
+	 * @account_id = account id
661
+	 */
662
+	function get_accounttax_by_id($account_id) {
663
+		$this->db->where("accountid", trim($account_id));
664
+		$query = $this->db->get("taxes_to_accounts");
665
+		if ($query->num_rows() > 0)
666
+			return $query->result_array();
667
+		else
668
+			return false;
669
+	}
670
+
671
+	/**
672
+	 * -------Here we write code for model accounting functions check_account_num------
673
+	 * this function write to verify the account number is valid or not.
674
+	 * @acc_num = account number
675
+	 */
676
+	function check_account_num($acc_num) {
677
+		$this->db->select('accountid');
678
+		$this->db->where("number", $acc_num);
679
+		$query = $this->db->get("accounts");
680
+
681
+		if ($query->num_rows() > 0)
682
+			return $query->row_array();
683
+		else
684
+			return false;
685
+	}
686
+
687
+	function get_account_by_number($id) {
688
+		$this->db->where("id", $id);
689
+		$query = $this->db->get("accounts");
690
+
691
+		if ($query->num_rows() > 0)
692
+			return $query->row_array();
693
+		else
694
+			return false;
695
+	}
696
+
697
+	function get_currency_by_id($currency_id) {
698
+
699
+		$query = $this->db_model->getSelect("*", 'currency', array('id' => $currency_id));
700
+		if ($query->num_rows() > 0)
701
+			return $query->row_array();
702
+		else
703
+			return false;
704
+	}
705
+
706
+
707
+	function update_balance($amount, $accountid, $payment_type) {
708
+		if ($payment_type == 0) {
709
+			$query = 'UPDATE `accounts` SET `balance` = (balance + ' . $amount . ') WHERE `id` = ' . $accountid;
710
+			return $this->db->query($query);
711
+		}if ($payment_type == 1) {
712
+			$query = 'UPDATE `accounts` SET `balance` = (balance - ' . $amount . ') WHERE `id` = ' . $accountid;
713
+			return $this->db->query($query);
714
+		}
715
+	}
716
+
717
+	function account_authentication($where_data, $id) {
718
+		if ($id != "") {
719
+			$this->db->where("id <>", $id);
720
+		}
721
+		$this->db->where($where_data);
722
+		$this->db->from("accounts");
723
+		$query = $this->db->count_all_results();
724
+		return $query;
725
+	}
726
+
727
+	function get_animap($flag, $start, $limit, $id) {
728
+		$where = array('accountid' => $id);
729
+
730
+		if ($flag) {
731
+			$query = $this->db_model->select("*", "ani_map", $where, "number", "DESC", $limit, $start);
732
+		} else {
733
+			$query = $this->db_model->countQuery("*", "ani_map", $where);
734
+		}
735
+		return $query;
736
+	}
737
+
738
+	function add_animap($data) {
739
+		$this->db->insert('ani_map', $data);
740
+		return true;
741
+	}
742
+
743
+	function edit_animap($data, $id) {
744
+		$new_array = array('number' => $data['number'], 'status' => $data['status']);
745
+		$this->db->where('id', $id);
746
+		$this->db->update('ani_map', $new_array);
747
+		return true;
748
+	}
749
+
750
+	function remove_ani_map($id) {
751
+		$this->db->where('id', $id);
752
+		$this->db->delete('ani_map');
753
+		return true;
754
+	}
755
+
756
+	function animap_authentication($where_data, $id) {
757
+		if ($id != "") {
758
+			$this->db->where("id <>", $id);
759
+		}
760
+		$this->db->where($where_data);
761
+		$this->db->from("ani_map");
762
+		$query = $this->db->count_all_results();
763
+		return $query;
764
+	}
765
+	function add_invoice_config($add_array) {
766
+		$result = $this->db->insert('invoice_conf', $add_array);
767
+		return true;
768
+	}
769
+
770
+	function edit_invoice_config($add_array, $edit_id) {
771
+		$this->db->where('id', $edit_id);
772
+		$result = $this->db->update('invoice_conf', $add_array);
773
+		return true;
774
+	}
775 775
 
776 776
 }
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/charges/controllers/charges.php 1 patch
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -24,177 +24,177 @@
 block discarded – undo
24 24
 
25 25
 class Charges extends MX_Controller {
26 26
 
27
-    function Charges() {
28
-        parent::__construct();
29
-
30
-        $this->load->helper('template_inheritance');
31
-
32
-        $this->load->library('session');
33
-        $this->load->library("charges_form");
34
-        $this->load->library('astpp/form');
35
-        $this->load->model('charges_model');
36
-
37
-        if ($this->session->userdata('user_login') == FALSE)
38
-            redirect(base_url() . '/astpp/login');
39
-    }
40
-
41
-    function periodiccharges_add() {
42
-        $data['username'] = $this->session->userdata('user_name');
43
-        $data['flag'] = 'create';
44
-        $data['page_title'] = 'Create Subscription';
45
-        $data['form'] = $this->form->build_form($this->charges_form->get_charge_form_fields(), '');
46
-        $this->load->view('view_periodiccharges_add_edit', $data);
47
-    }
48
-
49
-    function periodiccharges_edit($edit_id = '') {
50
-        $data['page_title'] = 'Edit Subscription ';
51
-        $where = array('id' => $edit_id);
52
-        $account = $this->db_model->getSelect("*", "charges", $where);
53
-        foreach ($account->result_array() as $key => $value) {
54
-            $edit_data = $value;
55
-        }
56
-        $edit_data['charge'] = $this->common_model->to_calculate_currency($edit_data['charge'], '', '', true, false);
27
+	function Charges() {
28
+		parent::__construct();
29
+
30
+		$this->load->helper('template_inheritance');
31
+
32
+		$this->load->library('session');
33
+		$this->load->library("charges_form");
34
+		$this->load->library('astpp/form');
35
+		$this->load->model('charges_model');
36
+
37
+		if ($this->session->userdata('user_login') == FALSE)
38
+			redirect(base_url() . '/astpp/login');
39
+	}
40
+
41
+	function periodiccharges_add() {
42
+		$data['username'] = $this->session->userdata('user_name');
43
+		$data['flag'] = 'create';
44
+		$data['page_title'] = 'Create Subscription';
45
+		$data['form'] = $this->form->build_form($this->charges_form->get_charge_form_fields(), '');
46
+		$this->load->view('view_periodiccharges_add_edit', $data);
47
+	}
48
+
49
+	function periodiccharges_edit($edit_id = '') {
50
+		$data['page_title'] = 'Edit Subscription ';
51
+		$where = array('id' => $edit_id);
52
+		$account = $this->db_model->getSelect("*", "charges", $where);
53
+		foreach ($account->result_array() as $key => $value) {
54
+			$edit_data = $value;
55
+		}
56
+		$edit_data['charge'] = $this->common_model->to_calculate_currency($edit_data['charge'], '', '', true, false);
57 57
         
58
-        $data['form'] = $this->form->build_form($this->charges_form->get_charge_form_fields(), $edit_data);
59
-        $this->load->view('view_periodiccharges_add_edit', $data);
60
-    }
61
-
62
-    function periodiccharges_save() {
63
-        $add_array = $this->input->post();
64
-        $data['form'] = $this->form->build_form($this->charges_form->get_charge_form_fields(), $add_array);
65
-        if ($add_array['id'] != '') {
66
-            $data['page_title'] = 'Edit Subscription';
67
-            if ($this->form_validation->run() == FALSE) {
68
-                $data['validation_errors'] = validation_errors();
69
-                echo $data['validation_errors'];
70
-                exit;
71
-            } else {
72
-                if ($add_array['pricelist_id'] == '') {
73
-                    $add_array['pricelist_id'] = '0';
74
-                }
75
-                $add_array['charge'] = $this->common_model->add_calculate_currency($add_array['charge'], '', '', false, false);
76
-                $this->charges_model->edit_charge($add_array, $add_array['id']);
58
+		$data['form'] = $this->form->build_form($this->charges_form->get_charge_form_fields(), $edit_data);
59
+		$this->load->view('view_periodiccharges_add_edit', $data);
60
+	}
61
+
62
+	function periodiccharges_save() {
63
+		$add_array = $this->input->post();
64
+		$data['form'] = $this->form->build_form($this->charges_form->get_charge_form_fields(), $add_array);
65
+		if ($add_array['id'] != '') {
66
+			$data['page_title'] = 'Edit Subscription';
67
+			if ($this->form_validation->run() == FALSE) {
68
+				$data['validation_errors'] = validation_errors();
69
+				echo $data['validation_errors'];
70
+				exit;
71
+			} else {
72
+				if ($add_array['pricelist_id'] == '') {
73
+					$add_array['pricelist_id'] = '0';
74
+				}
75
+				$add_array['charge'] = $this->common_model->add_calculate_currency($add_array['charge'], '', '', false, false);
76
+				$this->charges_model->edit_charge($add_array, $add_array['id']);
77 77
                 
78
-                if($add_array['pricelist_id'] > 0){
79
-                   $this->charges_model->add_account_charges($add_array['pricelist_id'],$add_array['id'],true);
80
-                }                
81
-                echo json_encode(array("SUCCESS"=> $add_array["description"]." subscription updated successfully!"));
82
-                exit;
83
-            }
84
-        } else {
85
-            $data['page_title'] = 'Add Subscription';
86
-            if ($this->form_validation->run() == FALSE) {
87
-                $data['validation_errors'] = validation_errors();
88
-                echo $data['validation_errors'];
89
-                exit;
90
-            } else {
91
-                $add_array['charge'] = $this->common_model->add_calculate_currency($add_array['charge'], '', '', false, false);
92
-                $charge_id = $this->charges_model->add_charge($add_array);
93
-                if($add_array['pricelist_id'] > 0 && $charge_id > 0){
94
-                   $this->charges_model->add_account_charges($add_array['pricelist_id'],$charge_id,false);
95
-                }                  
96
-                echo json_encode(array("SUCCESS"=> $add_array["description"]." subscription added successfully!"));
97
-                exit;
98
-            }
99
-        }
100
-    }
101
-
102
-
103
-
104
-    function periodiccharges_delete($id) {
105
-        $this->charges_model->remove_charge($id);
106
-        $this->session->set_flashdata('astpp_notification', 'Subscription removed successfully!');
107
-        redirect(base_url() . 'charges/periodiccharges/');
108
-    }
109
-
110
-    function periodiccharges_search() {
111
-        $ajax_search = $this->input->post('ajax_search', 0);
112
-        if ($this->input->post('advance_search', TRUE) == 1) {
113
-            $this->session->set_userdata('advance_search', $this->input->post('advance_search'));
114
-            $action = $this->input->post();
115
-            unset($action['action']);
116
-            unset($action['advance_search']);
117
-            if (isset($action['charge']['charge']) && $action['charge']['charge'] != '') {
118
-                $action['charge']['charge'] = $this->common_model->add_calculate_currency($action['charge']['charge'], "", '', true, false);
119
-            }
120
-            $this->session->set_userdata('charges_list_search', $action);
121
-        }
122
-        if (@$ajax_search != 1) {
123
-            redirect(base_url() . 'charges/periodiccharges/');
124
-        }
125
-    }
126
-
127
-    function periodiccharges_clearsearchfilter() {
128
-        $this->session->set_userdata('advance_search', 0);
129
-        $this->session->set_userdata('charges_list_search', "");
130
-    }
131
-
132
-    function periodiccharges() {
133
-        $data['username'] = $this->session->userdata('user_name');
134
-        $data['page_title'] = 'Subscriptions';
135
-        $data['search_flag'] = true;
136
-        $this->session->set_userdata('advance_search', 0);
137
-        $data['grid_fields'] = $this->charges_form->build_charge_list_for_admin();
138
-        $data["grid_buttons"] = $this->charges_form->build_grid_buttons();
139
-        $data['form_search'] = $this->form->build_serach_form($this->charges_form->get_charges_search_form());
140
-
141
-        $this->load->view('view_charges_list', $data);
142
-    }
143
-
144
-    /**
145
-     * -------Here we write code for controller accounts functions account_list------
146
-     * Listing of Accounts table data through php function json_encode
147
-     */
148
-    function periodiccharges_json() {
149
-        $json_data = array();
150
-        $count_all = $this->charges_model->getcharges_list(false);
151
-        $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
152
-        $json_data = $paging_data["json_paging"];
153
-        $query = $this->charges_model->getcharges_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]);
154
-        $grid_fields = json_decode($this->charges_form->build_charge_list_for_admin());
155
-        $json_data['rows'] = $this->form->build_grid($query, $grid_fields);
156
-
157
-        echo json_encode($json_data);
158
-    }
159
-
160
-    function periodiccharges_delete_multiple() {
161
-        $ids = $this->input->post("selected_ids", true);
162
-        $where = "id IN ($ids)";
163
-        $charge_where="charge_id IN(".$ids.")";
164
-        $this->db->delete('charge_to_account',$charge_where);
165
-        echo $this->db->delete("charges",$where);
166
-    }
167
-    function customer_charge_list($accountid, $accounttype) {
78
+				if($add_array['pricelist_id'] > 0){
79
+				   $this->charges_model->add_account_charges($add_array['pricelist_id'],$add_array['id'],true);
80
+				}                
81
+				echo json_encode(array("SUCCESS"=> $add_array["description"]." subscription updated successfully!"));
82
+				exit;
83
+			}
84
+		} else {
85
+			$data['page_title'] = 'Add Subscription';
86
+			if ($this->form_validation->run() == FALSE) {
87
+				$data['validation_errors'] = validation_errors();
88
+				echo $data['validation_errors'];
89
+				exit;
90
+			} else {
91
+				$add_array['charge'] = $this->common_model->add_calculate_currency($add_array['charge'], '', '', false, false);
92
+				$charge_id = $this->charges_model->add_charge($add_array);
93
+				if($add_array['pricelist_id'] > 0 && $charge_id > 0){
94
+				   $this->charges_model->add_account_charges($add_array['pricelist_id'],$charge_id,false);
95
+				}                  
96
+				echo json_encode(array("SUCCESS"=> $add_array["description"]." subscription added successfully!"));
97
+				exit;
98
+			}
99
+		}
100
+	}
101
+
102
+
103
+
104
+	function periodiccharges_delete($id) {
105
+		$this->charges_model->remove_charge($id);
106
+		$this->session->set_flashdata('astpp_notification', 'Subscription removed successfully!');
107
+		redirect(base_url() . 'charges/periodiccharges/');
108
+	}
109
+
110
+	function periodiccharges_search() {
111
+		$ajax_search = $this->input->post('ajax_search', 0);
112
+		if ($this->input->post('advance_search', TRUE) == 1) {
113
+			$this->session->set_userdata('advance_search', $this->input->post('advance_search'));
114
+			$action = $this->input->post();
115
+			unset($action['action']);
116
+			unset($action['advance_search']);
117
+			if (isset($action['charge']['charge']) && $action['charge']['charge'] != '') {
118
+				$action['charge']['charge'] = $this->common_model->add_calculate_currency($action['charge']['charge'], "", '', true, false);
119
+			}
120
+			$this->session->set_userdata('charges_list_search', $action);
121
+		}
122
+		if (@$ajax_search != 1) {
123
+			redirect(base_url() . 'charges/periodiccharges/');
124
+		}
125
+	}
126
+
127
+	function periodiccharges_clearsearchfilter() {
128
+		$this->session->set_userdata('advance_search', 0);
129
+		$this->session->set_userdata('charges_list_search', "");
130
+	}
131
+
132
+	function periodiccharges() {
133
+		$data['username'] = $this->session->userdata('user_name');
134
+		$data['page_title'] = 'Subscriptions';
135
+		$data['search_flag'] = true;
136
+		$this->session->set_userdata('advance_search', 0);
137
+		$data['grid_fields'] = $this->charges_form->build_charge_list_for_admin();
138
+		$data["grid_buttons"] = $this->charges_form->build_grid_buttons();
139
+		$data['form_search'] = $this->form->build_serach_form($this->charges_form->get_charges_search_form());
140
+
141
+		$this->load->view('view_charges_list', $data);
142
+	}
143
+
144
+	/**
145
+	 * -------Here we write code for controller accounts functions account_list------
146
+	 * Listing of Accounts table data through php function json_encode
147
+	 */
148
+	function periodiccharges_json() {
149
+		$json_data = array();
150
+		$count_all = $this->charges_model->getcharges_list(false);
151
+		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
152
+		$json_data = $paging_data["json_paging"];
153
+		$query = $this->charges_model->getcharges_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]);
154
+		$grid_fields = json_decode($this->charges_form->build_charge_list_for_admin());
155
+		$json_data['rows'] = $this->form->build_grid($query, $grid_fields);
156
+
157
+		echo json_encode($json_data);
158
+	}
159
+
160
+	function periodiccharges_delete_multiple() {
161
+		$ids = $this->input->post("selected_ids", true);
162
+		$where = "id IN ($ids)";
163
+		$charge_where="charge_id IN(".$ids.")";
164
+		$this->db->delete('charge_to_account',$charge_where);
165
+		echo $this->db->delete("charges",$where);
166
+	}
167
+	function customer_charge_list($accountid, $accounttype) {
168 168
 	
169
-        $json_data = array();
170
-
171
-        $select = "charge_to_account.id,charges.description,charges.charge,charges.sweep_id,charges.pro_rate,charges.creation_date,charges.last_modified_date";
172
-        $table = "charges";
173
-        $jionTable = array('charge_to_account', 'accounts');
174
-        $jionCondition = array('charges.id = charge_to_account.charge_id', 'accounts.id = charge_to_account.accountid');
175
-        $type = array('left', 'inner');
176
-        $where = array('accounts.id' => $accountid);
177
-        $order_type = 'id';
178
-        $order_by = "ASC";
179
-        $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_subscription'); 
180
-        $like_str=!empty($instant_search) ? "(charges.description like '%$instant_search%'  
169
+		$json_data = array();
170
+
171
+		$select = "charge_to_account.id,charges.description,charges.charge,charges.sweep_id,charges.pro_rate,charges.creation_date,charges.last_modified_date";
172
+		$table = "charges";
173
+		$jionTable = array('charge_to_account', 'accounts');
174
+		$jionCondition = array('charges.id = charge_to_account.charge_id', 'accounts.id = charge_to_account.accountid');
175
+		$type = array('left', 'inner');
176
+		$where = array('accounts.id' => $accountid);
177
+		$order_type = 'id';
178
+		$order_by = "ASC";
179
+		$instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_subscription'); 
180
+		$like_str=!empty($instant_search) ? "(charges.description like '%$instant_search%'  
181 181
                                             OR  charges.charge like '%$instant_search%'
182 182
                                             OR  charges.charge like '%$instant_search%' 
183 183
                                                 )"
184
-                                           :null;
185
-        if(!empty($like_str))
186
-        $this->db->where($like_str);
187
-        $count_all = $this->db_model->getCountWithJion($table, $select, $where, $jionTable, $jionCondition, $type);
188
-        $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
189
-        $json_data = $paging_data["json_paging"];
190
-        if(!empty($like_str))
191
-        $this->db->where($like_str);
192
-        $account_charge_list = $this->db_model->getAllJionQuery($table, $select, $where, $jionTable, $jionCondition, $type, $paging_data["paging"]["page_no"], $paging_data["paging"]["start"], $order_by, $order_type, "");
193
-        $grid_fields = json_decode($this->charges_form->build_charges_list_for_customer($accountid, $accounttype));
194
-        $json_data['rows'] = $this->form->build_grid($account_charge_list, $grid_fields);
195
-
196
-        echo json_encode($json_data);
197
-    }
184
+										   :null;
185
+		if(!empty($like_str))
186
+		$this->db->where($like_str);
187
+		$count_all = $this->db_model->getCountWithJion($table, $select, $where, $jionTable, $jionCondition, $type);
188
+		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
189
+		$json_data = $paging_data["json_paging"];
190
+		if(!empty($like_str))
191
+		$this->db->where($like_str);
192
+		$account_charge_list = $this->db_model->getAllJionQuery($table, $select, $where, $jionTable, $jionCondition, $type, $paging_data["paging"]["page_no"], $paging_data["paging"]["start"], $order_by, $order_type, "");
193
+		$grid_fields = json_decode($this->charges_form->build_charges_list_for_customer($accountid, $accounttype));
194
+		$json_data['rows'] = $this->form->build_grid($account_charge_list, $grid_fields);
195
+
196
+		echo json_encode($json_data);
197
+	}
198 198
 
199 199
 
200 200
     
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/charges/libraries/charges_form.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -23,119 +23,119 @@
 block discarded – undo
23 23
 ###############################################################################
24 24
 
25 25
 if (!defined('BASEPATH'))
26
-    exit('No direct script access allowed');
26
+	exit('No direct script access allowed');
27 27
 
28 28
 class Charges_form {
29
-      	function __construct($library_name = '') {
30
-        $this->CI = & get_instance();
31
-    }
29
+	  	function __construct($library_name = '') {
30
+		$this->CI = & get_instance();
31
+	}
32 32
    
33
-    function get_charge_form_fields() {
34
-        $form['forms'] = array(base_url() . 'charges/periodiccharges_save/', array('id' => 'charges_form', 'method' => 'POST', 'name' => 'charges_form'));
35
-        $form['Information'] = array(
36
-            array('', 'HIDDEN', array('name' => 'id'), '', '', '', ''),
37
-            array('Name', 'INPUT', array('name' => 'description', 'size' => '20', 'class' => "text field medium"), 'trim|required|xss_clean', 'tOOL TIP', 'Please Enter account number'),
38
-            array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'name', 'pricelists', 'build_dropdown', 'where_arr', array("reseller_id" => "0", "status <>" => "2")),
39
-            array('Amount', 'INPUT', array('name' => 'charge', 'size' => '20', 'class' => "text field medium"), 'trim|numeric|greater_than[0]|currency_decimal|xss_clean', 'tOOL TIP', 'Please Enter account number'),
40
-	    array('Prorate', 'pro_rate', 'SELECT', '', '', 'tOOL TIP', 'Please Select Pro rate', '', '', '', 'set_prorate'),      
41
-	    array('Bill cycle', 'sweep_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'sweep', 'sweeplist', 'build_dropdown', '', ''),
33
+	function get_charge_form_fields() {
34
+		$form['forms'] = array(base_url() . 'charges/periodiccharges_save/', array('id' => 'charges_form', 'method' => 'POST', 'name' => 'charges_form'));
35
+		$form['Information'] = array(
36
+			array('', 'HIDDEN', array('name' => 'id'), '', '', '', ''),
37
+			array('Name', 'INPUT', array('name' => 'description', 'size' => '20', 'class' => "text field medium"), 'trim|required|xss_clean', 'tOOL TIP', 'Please Enter account number'),
38
+			array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'name', 'pricelists', 'build_dropdown', 'where_arr', array("reseller_id" => "0", "status <>" => "2")),
39
+			array('Amount', 'INPUT', array('name' => 'charge', 'size' => '20', 'class' => "text field medium"), 'trim|numeric|greater_than[0]|currency_decimal|xss_clean', 'tOOL TIP', 'Please Enter account number'),
40
+		array('Prorate', 'pro_rate', 'SELECT', '', '', 'tOOL TIP', 'Please Select Pro rate', '', '', '', 'set_prorate'),      
41
+		array('Bill cycle', 'sweep_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'sweep', 'sweeplist', 'build_dropdown', '', ''),
42 42
 		array('Status', 'status', 'SELECT', '', '', 'tOOL TIP', 'Please Select Status', '', '', '', 'set_status'),
43
-        );
44
-        $form['button_cancel'] = array('name' => 'action', 'content' => 'Close', 'value' => 'cancel', 'type' => 'button', 'class' => 'btn btn-line-sky margin-x-10', 'onclick' => 'return redirect_page(\'NULL\')');
45
-        $form['button_save'] = array('name' => 'action', 'content' => 'Save', 'value' => 'save', 'id' => 'submit', 'type' => 'button', 'class' => 'btn btn-line-parrot');
46
-        return $form;
47
-    }
43
+		);
44
+		$form['button_cancel'] = array('name' => 'action', 'content' => 'Close', 'value' => 'cancel', 'type' => 'button', 'class' => 'btn btn-line-sky margin-x-10', 'onclick' => 'return redirect_page(\'NULL\')');
45
+		$form['button_save'] = array('name' => 'action', 'content' => 'Save', 'value' => 'save', 'id' => 'submit', 'type' => 'button', 'class' => 'btn btn-line-parrot');
46
+		return $form;
47
+	}
48 48
 
49
-    function get_charges_search_form() {
50
-    $logintype = $this->CI->session->userdata('logintype');
51
-        if ($logintype == 1 || $logintype == 5) {
52
-            $account_data = $this->CI->session->userdata("accountinfo");
53
-            $loginid = $account_data['id'];
49
+	function get_charges_search_form() {
50
+	$logintype = $this->CI->session->userdata('logintype');
51
+		if ($logintype == 1 || $logintype == 5) {
52
+			$account_data = $this->CI->session->userdata("accountinfo");
53
+			$loginid = $account_data['id'];
54 54
 
55
-        }else{
56
-            $loginid = "0";
57
-        }
58
-        $form['forms'] = array("", array('id' => "charges_search"));
59
-        $form['Search'] = array(
60
-            array('Name', 'INPUT', array('name' => 'description[description]', '', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'description[description-string]', '', '', '', 'search_string_type', ''),
61
-            array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'name', 'pricelists', 'build_dropdown', 'where_arr', array('status'=>0,'reseller_id'=>$loginid)),
55
+		}else{
56
+			$loginid = "0";
57
+		}
58
+		$form['forms'] = array("", array('id' => "charges_search"));
59
+		$form['Search'] = array(
60
+			array('Name', 'INPUT', array('name' => 'description[description]', '', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'description[description-string]', '', '', '', 'search_string_type', ''),
61
+			array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'name', 'pricelists', 'build_dropdown', 'where_arr', array('status'=>0,'reseller_id'=>$loginid)),
62 62
 			array('Amount', 'INPUT', array('name' => 'charge[charge]', 'value' => '', 'size' => '20', 'class' => "text field"), '', 'Tool tips info', '1', 'charge[charge-integer]', '', '', '', 'search_int_type', ''),
63 63
 			array('Billing Cycle', 'sweep_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'sweep', 'sweeplist', 'build_dropdown', '', ''), 
64 64
 			array('Status', 'status', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_search_status'),
65 65
 			array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),
66
-            array('', 'HIDDEN', 'advance_search', '1', '', '', '')
67
-        );
68
-        $form['button_search'] = array('name' => 'action', 'id' => "charges_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right');
69
-        $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10');
66
+			array('', 'HIDDEN', 'advance_search', '1', '', '', '')
67
+		);
68
+		$form['button_search'] = array('name' => 'action', 'id' => "charges_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right');
69
+		$form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10');
70 70
 
71
-        return $form;
72
-    }
73
-    /**
71
+		return $form;
72
+	}
73
+	/**
74 74
      ASTPP  3.0 
75 75
      Change size of grind 
76
-    **/
77
-    function build_charge_list_for_admin() {
76
+	 **/
77
+	function build_charge_list_for_admin() {
78 78
 		
79 79
 		  $account_info = $accountinfo = $this->CI->session->userdata('accountinfo');
80
-    $currency_id=$account_info['currency_id'];
81
-     $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id);
80
+	$currency_id=$account_info['currency_id'];
81
+	 $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id);
82 82
 		
83
-        // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
84
-        $grid_field_arr = json_encode(array(array("<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", "30", "", "", "", "","","false","center"),
83
+		// array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
84
+		$grid_field_arr = json_encode(array(array("<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", "30", "", "", "", "","","false","center"),
85 85
 /**
86 86
 ASTPP  3.0 
87 87
 For DID edit on DID number
88 88
 **/
89
-	    array(gettext("Name"), "140", "description", "", "", "","EDITABLE","true","center"),
89
+		array(gettext("Name"), "140", "description", "", "", "","EDITABLE","true","center"),
90 90
 /**************************************************/
91
-            array(gettext("Rate Group"), "140", "pricelist_id", "name", "pricelists", "get_field_name","","true","center"),
92
-            array("Amount($currency)", "125", "charge", "charge", "charge", "convert_to_currency","","true","right"),
93
-            array(gettext("Prorate"), "125", "pro_rate", "pro_rate", "charges", "get_prorate","","true","center"),
94
-            array(gettext("Billing Cycle"), "130", "sweep_id", "sweep", "sweeplist", "get_field_name","","true","center"),
95
-            /**
91
+			array(gettext("Rate Group"), "140", "pricelist_id", "name", "pricelists", "get_field_name","","true","center"),
92
+			array("Amount($currency)", "125", "charge", "charge", "charge", "convert_to_currency","","true","right"),
93
+			array(gettext("Prorate"), "125", "pro_rate", "pro_rate", "charges", "get_prorate","","true","center"),
94
+			array(gettext("Billing Cycle"), "130", "sweep_id", "sweep", "sweeplist", "get_field_name","","true","center"),
95
+			/**
96 96
 	    ASTPP  3.0 
97 97
 	    Show Creation date,last_modified date in reseller grid with admin login
98
-            **/
99
-            array(gettext("Status"), "125", "status", "status", "charges", "get_status","","true","center"),
100
-            array(gettext("Created Date"), "150", "creation_date", "", "", "","","true","center"),
101
-             array(gettext("Modified Date"), "150", "last_modified_date", "", "", "","","true","center"),
102
-            /************************************************/
103
-           /*
98
+			 **/
99
+			array(gettext("Status"), "125", "status", "status", "charges", "get_status","","true","center"),
100
+			array(gettext("Created Date"), "150", "creation_date", "", "", "","","true","center"),
101
+			 array(gettext("Modified Date"), "150", "last_modified_date", "", "", "","","true","center"),
102
+			/************************************************/
103
+		   /*
104 104
             ASTPP  3.0 
105 105
             change status active or inactive.
106 106
             */
107 107
             
108
-            /***********************************************/
109
-            array("Action", "150", "", "", "", array("EDIT" => array("url" => "charges/periodiccharges_edit/", "mode" => "popup", 'popup'),
110
-                    "DELETE" => array("url" => "charges/periodiccharges_delete/", "mode" => "single")))
111
-                ));
112
-        return $grid_field_arr;
113
-    }
114
-    /********************************************/
108
+			/***********************************************/
109
+			array("Action", "150", "", "", "", array("EDIT" => array("url" => "charges/periodiccharges_edit/", "mode" => "popup", 'popup'),
110
+					"DELETE" => array("url" => "charges/periodiccharges_delete/", "mode" => "single")))
111
+				));
112
+		return $grid_field_arr;
113
+	}
114
+	/********************************************/
115 115
 
116
-    function build_grid_buttons() {
117
-        $buttons_json = json_encode(array(array("Create" , "btn btn-line-warning btn" , "fa fa-plus-circle fa-lg", "button_action", "/charges/periodiccharges_add/", "popup"),
118
-            array("Delete", "btn btn-line-danger","fa fa-times-circle fa-lg",  "button_action", "/charges/periodiccharges_delete_multiple/")
119
-            ));
120
-        return $buttons_json;
121
-    }
116
+	function build_grid_buttons() {
117
+		$buttons_json = json_encode(array(array("Create" , "btn btn-line-warning btn" , "fa fa-plus-circle fa-lg", "button_action", "/charges/periodiccharges_add/", "popup"),
118
+			array("Delete", "btn btn-line-danger","fa fa-times-circle fa-lg",  "button_action", "/charges/periodiccharges_delete_multiple/")
119
+			));
120
+		return $buttons_json;
121
+	}
122 122
    
123
-    function build_charges_list_for_customer($accountid, $accounttype) {
123
+	function build_charges_list_for_customer($accountid, $accounttype) {
124 124
 		
125 125
 		$account_info = $accountinfo = $this->CI->session->userdata('accountinfo');
126 126
 		$currency_id=$account_info['currency_id'];
127 127
 		$currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id);		
128 128
 		
129
-        $grid_field_arr = json_encode(array(array("Name", "140", "description", "", "", "","","true","center"),
130
-            array("Amount($currency)", "140", "charge", "charge", "charge", "convert_to_currency","","true","right"),
131
-            array("Prorate", "125", "pro_rate", "pro_rate", "charges", "get_prorate","","true","center"),
132
-            array("Billing Cycle", "170", "sweep_id", "sweep", "sweeplist", "get_field_name","","true","center"),
133
-            array("Created Date", "150", "creation_date", "", "", "","","true","center"),
134
-             array("Modified Date", "150", "last_modified_date", "", "", "","","true","center"),
135
-            array("Action", "150", "", "", "", array("DELETE" => array("url" => "accounts/".$accounttype."_subscription_action/delete/$accountid/$accounttype/", "mode" => "single")))
136
-                ));
137
-        return $grid_field_arr;
138
-    }   
129
+		$grid_field_arr = json_encode(array(array("Name", "140", "description", "", "", "","","true","center"),
130
+			array("Amount($currency)", "140", "charge", "charge", "charge", "convert_to_currency","","true","right"),
131
+			array("Prorate", "125", "pro_rate", "pro_rate", "charges", "get_prorate","","true","center"),
132
+			array("Billing Cycle", "170", "sweep_id", "sweep", "sweeplist", "get_field_name","","true","center"),
133
+			array("Created Date", "150", "creation_date", "", "", "","","true","center"),
134
+			 array("Modified Date", "150", "last_modified_date", "", "", "","","true","center"),
135
+			array("Action", "150", "", "", "", array("DELETE" => array("url" => "accounts/".$accounttype."_subscription_action/delete/$accountid/$accounttype/", "mode" => "single")))
136
+				));
137
+		return $grid_field_arr;
138
+	}   
139 139
 
140 140
 }
141 141
 
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/charges/models/charges_model.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -24,105 +24,105 @@
 block discarded – undo
24 24
 
25 25
 class Charges_model extends CI_Model {
26 26
 
27
-    function Charges_model() {
28
-        parent::__construct();
29
-    }
27
+	function Charges_model() {
28
+		parent::__construct();
29
+	}
30 30
 
31
-    function getcharges_list($flag, $start = 0, $limit = 0) {
32
-        $this->db_model->build_search('charges_list_search');
33
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
34
-            $account_data = $this->session->userdata("accountinfo");
35
-            $reseller = $account_data['id'];
36
-            $where = array("reseller_id" => $reseller);
37
-        } else {
38
-            $where = array("reseller_id" => "0");
39
-        }
40
-        if ($flag) {
41
-            $query = $this->db_model->select("*", "charges", $where, "id", "ASC", $limit, $start);
42
-        } else {
43
-            $query = $this->db_model->countQuery("*", "charges", $where);
44
-        }
45
-        return $query;
46
-    }
31
+	function getcharges_list($flag, $start = 0, $limit = 0) {
32
+		$this->db_model->build_search('charges_list_search');
33
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
34
+			$account_data = $this->session->userdata("accountinfo");
35
+			$reseller = $account_data['id'];
36
+			$where = array("reseller_id" => $reseller);
37
+		} else {
38
+			$where = array("reseller_id" => "0");
39
+		}
40
+		if ($flag) {
41
+			$query = $this->db_model->select("*", "charges", $where, "id", "ASC", $limit, $start);
42
+		} else {
43
+			$query = $this->db_model->countQuery("*", "charges", $where);
44
+		}
45
+		return $query;
46
+	}
47 47
 
48
-    function add_charge($add_array) {
49
-        /*
48
+	function add_charge($add_array) {
49
+		/*
50 50
 	 ASTPP  3.0 
51 51
          Charges Add time last creation date update
52 52
         */
53
-        $add_array['creation_date'] = gmdate('Y-m-d H:i:s');
54
-        /**********************************************************************************************/
55
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
56
-            $account_data = $this->session->userdata("accountinfo");
57
-            $add_array['reseller_id'] = $account_data['id'];
58
-        } else {
59
-            $add_array['reseller_id'] = "0";
60
-        }
53
+		$add_array['creation_date'] = gmdate('Y-m-d H:i:s');
54
+		/**********************************************************************************************/
55
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
56
+			$account_data = $this->session->userdata("accountinfo");
57
+			$add_array['reseller_id'] = $account_data['id'];
58
+		} else {
59
+			$add_array['reseller_id'] = "0";
60
+		}
61 61
 
62
-        unset($add_array['action']);
63
-        $this->db->insert("charges", $add_array);
64
-        $insert_id = $this->db->insert_id(); 
65
-        $data = $this->db_model->getSelect("*", "accounts", array("pricelist_id" => $add_array['pricelist_id']));
66
-        if($data->num_rows > 0){
67
-           foreach ($data->result_array() as $key => $value){
68
-                $this->common->mail_to_users('add_subscription', $value);  
69
-           }
70
-        }
71
-        return $insert_id;
72
-    }
62
+		unset($add_array['action']);
63
+		$this->db->insert("charges", $add_array);
64
+		$insert_id = $this->db->insert_id(); 
65
+		$data = $this->db_model->getSelect("*", "accounts", array("pricelist_id" => $add_array['pricelist_id']));
66
+		if($data->num_rows > 0){
67
+		   foreach ($data->result_array() as $key => $value){
68
+				$this->common->mail_to_users('add_subscription', $value);  
69
+		   }
70
+		}
71
+		return $insert_id;
72
+	}
73 73
 
74
-    function edit_charge($data, $id) {
75
-        unset($data['action']);
76
-        /*
74
+	function edit_charge($data, $id) {
75
+		unset($data['action']);
76
+		/*
77 77
        ASTPP  3.0 
78 78
         Charges edit time last modified date update
79 79
         */
80
-        $data['last_modified_date'] = gmdate('Y-m-d H:i:s');
81
-        /**********************************************************************************************/
82
-        if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
83
-            $account_data = $this->session->userdata("accountinfo");
84
-            $data['reseller_id'] = $account_data['id'];
85
-        } else {
86
-            $data['reseller_id'] = "0";
87
-        }
88
-        $this->db->where("id", $id);
89
-        $this->db->update("charges", $data);
80
+		$data['last_modified_date'] = gmdate('Y-m-d H:i:s');
81
+		/**********************************************************************************************/
82
+		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) {
83
+			$account_data = $this->session->userdata("accountinfo");
84
+			$data['reseller_id'] = $account_data['id'];
85
+		} else {
86
+			$data['reseller_id'] = "0";
87
+		}
88
+		$this->db->where("id", $id);
89
+		$this->db->update("charges", $data);
90 90
         
91
-        if($data['pricelist_id'] == 0){
91
+		if($data['pricelist_id'] == 0){
92 92
 			$this->db->where("charge_id", $id);
93 93
 			$this->db->delete("charge_to_account");
94 94
 		}
95
-    }
95
+	}
96 96
 
97
-    function remove_charge($id) {
97
+	function remove_charge($id) {
98 98
 		$this->db->where("id", $id);
99 99
 		$this->db->delete("charges");
100 100
 		$this->db->where("charge_id", $id);
101
-        $this->db->delete("charge_to_account");
102
-        $data = $this->db_model->getSelect("*", "charges", array("id" => $id));
103
-        $data = $data->result_array();
104
-        $data = $data[0];
105
-        $data = $this->db_model->getSelect("*", "accounts", array("pricelist_id" => $data['pricelist_id']));
106
-        if($data->num_rows > 0){
107
-           foreach ($data->result_array() as $key => $value){
108
-                $this->common->mail_to_users('remove_subscription', $value);  
109
-           }
110
-        }
111
-        return true;
112
-    }
101
+		$this->db->delete("charge_to_account");
102
+		$data = $this->db_model->getSelect("*", "charges", array("id" => $id));
103
+		$data = $data->result_array();
104
+		$data = $data[0];
105
+		$data = $this->db_model->getSelect("*", "accounts", array("pricelist_id" => $data['pricelist_id']));
106
+		if($data->num_rows > 0){
107
+		   foreach ($data->result_array() as $key => $value){
108
+				$this->common->mail_to_users('remove_subscription', $value);  
109
+		   }
110
+		}
111
+		return true;
112
+	}
113 113
     
114
-    function add_account_charges($pricelistid,$chargeid,$flag){
115
-        if($flag){
116
-           $this->db->where("charge_id", $chargeid);
117
-           $this->db->delete("charge_to_account");
118
-        }
119
-        $account = $this->db_model->getSelect("*", "accounts", array("pricelist_id"=>$pricelistid));
120
-        if($account->num_rows > 0){
121
-           foreach ($account->result_array() as $key => $value){
122
-                $charge_arr = array("charge_id"=>$chargeid,"accountid"=>$value['id'],"assign_date"=>gmdate("Y-m-d H:i:s"));
123
-                $this->db->insert("charge_to_account", $charge_arr);               
124
-           }
125
-        }
126
-    }
114
+	function add_account_charges($pricelistid,$chargeid,$flag){
115
+		if($flag){
116
+		   $this->db->where("charge_id", $chargeid);
117
+		   $this->db->delete("charge_to_account");
118
+		}
119
+		$account = $this->db_model->getSelect("*", "accounts", array("pricelist_id"=>$pricelistid));
120
+		if($account->num_rows > 0){
121
+		   foreach ($account->result_array() as $key => $value){
122
+				$charge_arr = array("charge_id"=>$chargeid,"accountid"=>$value['id'],"assign_date"=>gmdate("Y-m-d H:i:s"));
123
+				$this->db->insert("charge_to_account", $charge_arr);               
124
+		   }
125
+		}
126
+	}
127 127
 
128 128
 }
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/did/controllers/did.php 1 patch
Indentation   +694 added lines, -694 removed lines patch added patch discarded remove patch
@@ -24,128 +24,128 @@  discard block
 block discarded – undo
24 24
 
25 25
 class DID extends MX_Controller {
26 26
 
27
-    function DID() {
28
-        parent::__construct();
29
-
30
-        $this->load->helper('template_inheritance');
31
-        $this->load->library('session');
32
-        $this->load->library('did_form');
33
-        $this->load->library('astpp/form');
34
-        $this->load->model('did_model');
35
-        $this->load->library('csvreader');
36
-
37
-        if ($this->session->userdata('user_login') == FALSE)
38
-            redirect(base_url() . '/astpp/login');
39
-    }
40
-
41
-    function did_add() {
42
-        $data['page_title'] = 'Create DID';
43
-        $data['form'] = $this->form->build_form($this->did_form->get_dids_form_fields(), '');
44
-        $data['country_id'] = $this->common->get_field_name('id', 'countrycode', array('country' => Common_model::$global_config['system_config']['country']));
45
-        if (!$data['country_id']) {
46
-            $data['country_id'] = 1;
47
-        }
48
-        $this->load->view('view_did_add_edit', $data);
49
-    }
50
-
51
-    function did_edit($edit_id = '') {
52
-        $data['page_title'] = 'Edit DID';
53
-        $where = array('id' => $edit_id);
54
-        $account = $this->db_model->getSelect("*", "dids", $where);
55
-        foreach ($account->result_array() as $value) {
56
-            $edit_data = $value;
57
-        }
58
-        /**
27
+	function DID() {
28
+		parent::__construct();
29
+
30
+		$this->load->helper('template_inheritance');
31
+		$this->load->library('session');
32
+		$this->load->library('did_form');
33
+		$this->load->library('astpp/form');
34
+		$this->load->model('did_model');
35
+		$this->load->library('csvreader');
36
+
37
+		if ($this->session->userdata('user_login') == FALSE)
38
+			redirect(base_url() . '/astpp/login');
39
+	}
40
+
41
+	function did_add() {
42
+		$data['page_title'] = 'Create DID';
43
+		$data['form'] = $this->form->build_form($this->did_form->get_dids_form_fields(), '');
44
+		$data['country_id'] = $this->common->get_field_name('id', 'countrycode', array('country' => Common_model::$global_config['system_config']['country']));
45
+		if (!$data['country_id']) {
46
+			$data['country_id'] = 1;
47
+		}
48
+		$this->load->view('view_did_add_edit', $data);
49
+	}
50
+
51
+	function did_edit($edit_id = '') {
52
+		$data['page_title'] = 'Edit DID';
53
+		$where = array('id' => $edit_id);
54
+		$account = $this->db_model->getSelect("*", "dids", $where);
55
+		foreach ($account->result_array() as $value) {
56
+			$edit_data = $value;
57
+		}
58
+		/**
59 59
           ASTPP  3.0 
60 60
           In DID Edit Country Field not change
61
-         * */
62
-        $data['country_id'] = $edit_data['country_id'];
63
-        if ($edit_data['country_id'] == "") {
64
-            $data['country_id'] = Common_model::$global_config['system_config']['country'];
65
-        }
66
-        /*         * ************************************************* */
67
-        if (!$data['country_id']) {
68
-            $data['country_id'] = 1;
69
-        }
70
-        $edit_data['setup'] = $this->common_model->to_calculate_currency($edit_data['setup'], '', '', false, false);
71
-        $edit_data['monthlycost'] = $this->common_model->to_calculate_currency($edit_data['monthlycost'], '', '', false, false);
72
-        $edit_data['connectcost'] = $this->common_model->to_calculate_currency($edit_data['connectcost'], '', '', false, false);
73
-        $edit_data['cost'] = $this->common_model->to_calculate_currency($edit_data['cost'], '', '', false, false);
74
-        $parent_id = $edit_data['parent_id'];
75
-        $account_id = $edit_data['accountid'];
76
-        if ($parent_id > 0) {
77
-            $data['form'] = $this->form->build_form($this->did_form->get_dids_form_fields($edit_id, $parent_id, $account_id), $edit_data);
78
-        } else {
79
-            $data['form'] = $this->form->build_form($this->did_form->get_dids_form_fields($edit_id, '', $account_id), $edit_data);
80
-        }
81
-        $this->load->view('view_did_add_edit', $data);
82
-    }
83
-
84
-    function did_save() {
85
-        $add_array = $this->input->post();
86
-        $parent_id =isset($add_array['parent_id']) && $add_array['parent_id'] >0 ? $add_array['parent_id'] : '';
87
-        $accountid =isset($add_array['accountid']) && $add_array['accountid'] > 0 ? $add_array['accountid'] : '';
88
-        $data['form'] = $this->form->build_form($this->did_form->get_dids_form_fields($add_array['id'],$parent_id,$accountid), $add_array);
89
-        if ($add_array['id'] != '') {
90
-            $data['page_title'] = 'Edit DID';
91
-            if ($this->form_validation->run() == FALSE) {
92
-                $data['validation_errors'] = validation_errors();
93
-                echo $data['validation_errors'];
94
-                exit;
95
-            } else {
96
-                $number = $add_array['number'];
97
-                unset($add_array['number']);
98
-                $add_array['accountid']=isset($add_array['accountid']) ?$add_array['accountid'] : 0;
99
-                $add_array['setup'] = $this->common_model->add_calculate_currency($add_array['setup'], '', '', false, false);
100
-                $add_array['monthlycost'] = $this->common_model->add_calculate_currency($add_array['monthlycost'], '', '', false, false);
101
-                $add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false);
102
-                $add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false);
103
-                $this->did_model->edit_did($add_array, $add_array['id'], $number);
104
-                echo json_encode(array("SUCCESS" => $number . " DID Updated Successfully!"));
105
-                exit;
106
-            }
107
-        } else {
108
-            $data['page_title'] = 'Add DID';
109
-            if ($this->form_validation->run() == FALSE) {
110
-                $data['validation_errors'] = validation_errors();
111
-                echo $data['validation_errors'];
112
-                exit;
113
-            } else {
114
-                $check_did_number = $this->did_model->check_unique_did($add_array['number']);
115
-                if ($check_did_number > 0) {
116
-                    echo json_encode(array("number_error" => "Number already exist in system."));
117
-                    exit;
118
-                }
119
-                $add_array['setup'] = $this->common_model->add_calculate_currency($add_array['setup'], '', '', false, false);
120
-                $add_array['monthlycost'] = $this->common_model->add_calculate_currency($add_array['monthlycost'], '', '', false, false);
121
-                $add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false);
122
-                $add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false);
123
-                $add_array['accountid']=isset($add_array['accountid'])?$add_array['accountid'] : 0;
124
-                $this->did_model->add_did($add_array);
125
-                echo json_encode(array("SUCCESS" => $add_array["number"] . " DID Added Successfully!"));
126
-                exit;
127
-                exit;
128
-            }
129
-        }
130
-    }
131
-
132
-    function did_remove($id) {
133
-        $this->did_model->remove_did($id);
134
-        $this->session->set_flashdata('astpp_notification', 'DID Removed Successfully!');
135
-        redirect(base_url() . 'did/did_list/');
136
-    }
137
-
138
-    /*
61
+		 * */
62
+		$data['country_id'] = $edit_data['country_id'];
63
+		if ($edit_data['country_id'] == "") {
64
+			$data['country_id'] = Common_model::$global_config['system_config']['country'];
65
+		}
66
+		/*         * ************************************************* */
67
+		if (!$data['country_id']) {
68
+			$data['country_id'] = 1;
69
+		}
70
+		$edit_data['setup'] = $this->common_model->to_calculate_currency($edit_data['setup'], '', '', false, false);
71
+		$edit_data['monthlycost'] = $this->common_model->to_calculate_currency($edit_data['monthlycost'], '', '', false, false);
72
+		$edit_data['connectcost'] = $this->common_model->to_calculate_currency($edit_data['connectcost'], '', '', false, false);
73
+		$edit_data['cost'] = $this->common_model->to_calculate_currency($edit_data['cost'], '', '', false, false);
74
+		$parent_id = $edit_data['parent_id'];
75
+		$account_id = $edit_data['accountid'];
76
+		if ($parent_id > 0) {
77
+			$data['form'] = $this->form->build_form($this->did_form->get_dids_form_fields($edit_id, $parent_id, $account_id), $edit_data);
78
+		} else {
79
+			$data['form'] = $this->form->build_form($this->did_form->get_dids_form_fields($edit_id, '', $account_id), $edit_data);
80
+		}
81
+		$this->load->view('view_did_add_edit', $data);
82
+	}
83
+
84
+	function did_save() {
85
+		$add_array = $this->input->post();
86
+		$parent_id =isset($add_array['parent_id']) && $add_array['parent_id'] >0 ? $add_array['parent_id'] : '';
87
+		$accountid =isset($add_array['accountid']) && $add_array['accountid'] > 0 ? $add_array['accountid'] : '';
88
+		$data['form'] = $this->form->build_form($this->did_form->get_dids_form_fields($add_array['id'],$parent_id,$accountid), $add_array);
89
+		if ($add_array['id'] != '') {
90
+			$data['page_title'] = 'Edit DID';
91
+			if ($this->form_validation->run() == FALSE) {
92
+				$data['validation_errors'] = validation_errors();
93
+				echo $data['validation_errors'];
94
+				exit;
95
+			} else {
96
+				$number = $add_array['number'];
97
+				unset($add_array['number']);
98
+				$add_array['accountid']=isset($add_array['accountid']) ?$add_array['accountid'] : 0;
99
+				$add_array['setup'] = $this->common_model->add_calculate_currency($add_array['setup'], '', '', false, false);
100
+				$add_array['monthlycost'] = $this->common_model->add_calculate_currency($add_array['monthlycost'], '', '', false, false);
101
+				$add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false);
102
+				$add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false);
103
+				$this->did_model->edit_did($add_array, $add_array['id'], $number);
104
+				echo json_encode(array("SUCCESS" => $number . " DID Updated Successfully!"));
105
+				exit;
106
+			}
107
+		} else {
108
+			$data['page_title'] = 'Add DID';
109
+			if ($this->form_validation->run() == FALSE) {
110
+				$data['validation_errors'] = validation_errors();
111
+				echo $data['validation_errors'];
112
+				exit;
113
+			} else {
114
+				$check_did_number = $this->did_model->check_unique_did($add_array['number']);
115
+				if ($check_did_number > 0) {
116
+					echo json_encode(array("number_error" => "Number already exist in system."));
117
+					exit;
118
+				}
119
+				$add_array['setup'] = $this->common_model->add_calculate_currency($add_array['setup'], '', '', false, false);
120
+				$add_array['monthlycost'] = $this->common_model->add_calculate_currency($add_array['monthlycost'], '', '', false, false);
121
+				$add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false);
122
+				$add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false);
123
+				$add_array['accountid']=isset($add_array['accountid'])?$add_array['accountid'] : 0;
124
+				$this->did_model->add_did($add_array);
125
+				echo json_encode(array("SUCCESS" => $add_array["number"] . " DID Added Successfully!"));
126
+				exit;
127
+				exit;
128
+			}
129
+		}
130
+	}
131
+
132
+	function did_remove($id) {
133
+		$this->did_model->remove_did($id);
134
+		$this->session->set_flashdata('astpp_notification', 'DID Removed Successfully!');
135
+		redirect(base_url() . 'did/did_list/');
136
+	}
137
+
138
+	/*
139 139
       ASTPP  3.0
140 140
       function Spelling change.
141 141
      */
142 142
 
143
-    function did_list_release($id) {
144
-     $accountinfo=$this->session->userdata('accountinfo'); 
145
-     $this->db->where('id',$id);
146
-     $this->db->select('parent_id,accountid,number');
147
-     $did_info=(array)$this->db->get('dids')->first_row();
148
-     if($did_info['parent_id'] > 0){
143
+	function did_list_release($id) {
144
+	 $accountinfo=$this->session->userdata('accountinfo'); 
145
+	 $this->db->where('id',$id);
146
+	 $this->db->select('parent_id,accountid,number');
147
+	 $did_info=(array)$this->db->get('dids')->first_row();
148
+	 if($did_info['parent_id'] > 0){
149 149
 	$str=$this->common->get_parent_info($did_info['parent_id'],$accountinfo['id']);
150 150
 	$str=rtrim($str,",");
151 151
 	$account_result=(array)$this->db->get_where('accounts',"id IN (".$str.")")->result_array();
@@ -153,176 +153,176 @@  discard block
 block discarded – undo
153 153
 	   $acc_row['did_number']=$did_info['number'];
154 154
 	   $this->common->mail_to_users('email_remove_did', $acc_row);
155 155
 	}
156
-     }
157
-     if($accountinfo['type'] == -1){
156
+	 }
157
+	 if($accountinfo['type'] == -1){
158 158
 	  $update_array = array('parent_id' => 0, 'accountid' => 0, 'assign_date' => '0000-00-00 00:00:00', "charge_upto" => "0000-00-00 00:00:00","last_modified_date"=>gmdate("Y-m-d H:i:s"));
159 159
 	  $where = array('id' => $id);
160 160
 	  $this->db->where($where);
161 161
 	  $this->db->update('dids', $update_array);
162 162
 	  if($did_info['parent_id'] > 0){
163
-	    $this->db->where('note',$did_info['number']);
164
-	    $this->db->delete("reseller_pricing");
163
+		$this->db->where('note',$did_info['number']);
164
+		$this->db->delete("reseller_pricing");
165 165
 	  }
166
-      }else{
166
+	  }else{
167 167
 	  $reseller_ids=$this->common->get_subreseller_info($accountinfo['id']);
168 168
 	  $reseller_ids=rtrim($reseller_ids,",");
169 169
 	  $where="parent_id IN ($reseller_ids)";
170 170
 	  $this->db->where('note',$did_info['number']);
171 171
 	  $this->db->delete('reseller_pricing',$where);  
172
-      }
173
-      if($accountinfo['type']==1){
174
-          $update_array = array('parent_id' => $accountinfo['id'], 'accountid' => 0, 'assign_date' => '0000-00-00 00:00:00', "charge_upto" => "0000-00-00 00:00:00","last_modified_date"=>gmdate("Y-m-d H:i:s"));
175
-      }else{
172
+	  }
173
+	  if($accountinfo['type']==1){
174
+		  $update_array = array('parent_id' => $accountinfo['id'], 'accountid' => 0, 'assign_date' => '0000-00-00 00:00:00', "charge_upto" => "0000-00-00 00:00:00","last_modified_date"=>gmdate("Y-m-d H:i:s"));
175
+	  }else{
176 176
 	  $update_array = array('parent_id' => 0, 'accountid' => 0, 'assign_date' => '0000-00-00 00:00:00', "charge_upto" => "0000-00-00 00:00:00","last_modified_date"=>gmdate("Y-m-d H:i:s"));
177
-      }
178
-      $where = array('id' => $id);
179
-      $this->db->where($where);
180
-      $this->db->update('dids', $update_array);
181
-      $accountid=$did_info['accountid'] > 0 ? $did_info['accountid']:0;
182
-      if($did_info['accountid'] > 0 ){
183
-       $email_user_id=$did_info['accountid'];
184
-      }elseif($did_info['parent_id'] > 0){
177
+	  }
178
+	  $where = array('id' => $id);
179
+	  $this->db->where($where);
180
+	  $this->db->update('dids', $update_array);
181
+	  $accountid=$did_info['accountid'] > 0 ? $did_info['accountid']:0;
182
+	  if($did_info['accountid'] > 0 ){
183
+	   $email_user_id=$did_info['accountid'];
184
+	  }elseif($did_info['parent_id'] > 0){
185 185
 	$email_user_id=$did_info['parent_id'];
186
-      }
187
-      $accountinfo=(array)$this->db->get_where('accounts',array("id"=>$email_user_id))->first_row();
188
-      $accountinfo['did_number'] = $did_info['number'];
189
-      $this->common->mail_to_users('email_remove_did', $accountinfo);
190
-      $this->session->set_flashdata('astpp_errormsg', 'DID Released Successfully!');
191
-      redirect(base_url() . 'did/did_list/');
192
-    }
193
-
194
-    function did_list() {
195
-        $data['app_name'] = 'ASTPP - Open Source Billing Solution | Manage DIDs | DIDS';
196
-        $data['username'] = $this->session->userdata('user_name');
197
-        $data['page_title'] = gettext('DIDs');
198
-        $data['search_flag'] = true;
199
-        $this->session->set_userdata('did_search', 0);
200
-        if ($this->session->userdata('logintype') == 2) {
201
-            $data["grid_buttons"] = $this->did_form->build_grid_buttons();
202
-        } else {
203
-            $data["grid_buttons"] = json_encode(array());
204
-        }
186
+	  }
187
+	  $accountinfo=(array)$this->db->get_where('accounts',array("id"=>$email_user_id))->first_row();
188
+	  $accountinfo['did_number'] = $did_info['number'];
189
+	  $this->common->mail_to_users('email_remove_did', $accountinfo);
190
+	  $this->session->set_flashdata('astpp_errormsg', 'DID Released Successfully!');
191
+	  redirect(base_url() . 'did/did_list/');
192
+	}
193
+
194
+	function did_list() {
195
+		$data['app_name'] = 'ASTPP - Open Source Billing Solution | Manage DIDs | DIDS';
196
+		$data['username'] = $this->session->userdata('user_name');
197
+		$data['page_title'] = gettext('DIDs');
198
+		$data['search_flag'] = true;
199
+		$this->session->set_userdata('did_search', 0);
200
+		if ($this->session->userdata('logintype') == 2) {
201
+			$data["grid_buttons"] = $this->did_form->build_grid_buttons();
202
+		} else {
203
+			$data["grid_buttons"] = json_encode(array());
204
+		}
205 205
          
206
-        if ($this->session->userdata['userlevel_logintype'] == '1') {
207
-	    $drp_list=array();
208
-	    $accountinfo = $this->session->userdata('accountinfo');
209
-	    if($accountinfo['reseller_id'] > 0){
210
-	      $dids_array=$this->db->query("SELECT a.id AS id,a.number as number, b.monthlycost, b.setup FROM dids AS a, reseller_pricing AS b WHERE a.number = b.note AND b.reseller_id = ".$accountinfo['reseller_id']." AND a.parent_id =".$accountinfo['reseller_id'])->result_array();
211
-            }else{
212
-              $this->db->select('id,monthlycost,setup,number');
213
-              $this->db->where('accountid',0);
214
-              $this->db->where('parent_id',0);
215
-              $dids_array=$this->db->get('dids')->result_array();
216
-            }
217
-            if(!empty($dids_array)){
206
+		if ($this->session->userdata['userlevel_logintype'] == '1') {
207
+		$drp_list=array();
208
+		$accountinfo = $this->session->userdata('accountinfo');
209
+		if($accountinfo['reseller_id'] > 0){
210
+		  $dids_array=$this->db->query("SELECT a.id AS id,a.number as number, b.monthlycost, b.setup FROM dids AS a, reseller_pricing AS b WHERE a.number = b.note AND b.reseller_id = ".$accountinfo['reseller_id']." AND a.parent_id =".$accountinfo['reseller_id'])->result_array();
211
+			}else{
212
+			  $this->db->select('id,monthlycost,setup,number');
213
+			  $this->db->where('accountid',0);
214
+			  $this->db->where('parent_id',0);
215
+			  $dids_array=$this->db->get('dids')->result_array();
216
+			}
217
+			if(!empty($dids_array)){
218 218
 		foreach ($dids_array as $drp_value) {
219
-		    if (!empty($drp_value['monthlycost']) && $drp_value['monthlycost'] != 0) {
219
+			if (!empty($drp_value['monthlycost']) && $drp_value['monthlycost'] != 0) {
220 220
 			$did_cost = $this->common_model->to_calculate_currency($drp_value['monthlycost'], '', '', true, false);
221
-		    } else {
221
+			} else {
222 222
 			$did_cost = 0;
223
-		    }
224
-		    if (!empty($drp_value['setup']) && $drp_value['setup'] != 0) {
223
+			}
224
+			if (!empty($drp_value['setup']) && $drp_value['setup'] != 0) {
225 225
 			$did_setup = $this->common_model->to_calculate_currency($drp_value['setup'], '', '', true, false);
226
-		    } else {
226
+			} else {
227 227
 			$did_setup = 0;
228
-		    }
229
-		    $drp_list[$drp_value['id']] = $drp_value['number'] . ' ( Setup : ' . $did_setup . ')' . '( Monthly : ' . $did_cost . ' )';
230
-		    /*                 * ********************************************************************************************* */
228
+			}
229
+			$drp_list[$drp_value['id']] = $drp_value['number'] . ' ( Setup : ' . $did_setup . ')' . '( Monthly : ' . $did_cost . ' )';
230
+			/*                 * ********************************************************************************************* */
231
+		}
231 232
 		}
232
-	    }
233 233
 	  $data['didlist'] = form_dropdown_all(array("name"=>"free_did_list","id"=>"free_did_list","class"=>"did_dropdown"), $drp_list, '');
234
-        }
235
-        if ($this->session->userdata['userlevel_logintype'] == '1') {
236
-            $data['grid_fields'] = $this->did_form->build_did_list_for_reseller_login();
237
-            $data['form_search'] = $this->form->build_serach_form($this->did_form->get_search_did_form_for_reseller());
238
-        } else {
239
-            $data['grid_fields'] = $this->did_form->build_did_list_for_admin();
240
-            $data['form_search'] = $this->form->build_serach_form($this->did_form->get_search_did_form());
241
-        }
242
-        $this->load->view('view_did_list', $data);
243
-    }
244
-
245
-    /**
246
-     * -------Here we write code for controller accounts functions account_list------
247
-     * Listing of Accounts table data through php function json_encode
248
-     */
249
-    function did_list_json() {
250
-        $json_data = array();
251
-
252
-        $count_all = $this->did_model->getdid_list(false);
253
-        $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
254
-        $json_data = $paging_data["json_paging"];
255
-        $list = $this->session->userdata['userlevel_logintype'] == 1 ? $this->did_form->build_did_list_for_reseller_login() : $this->did_form->build_did_list_for_admin();
256
-        $query = $this->did_model->getdid_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]);
257
-        $grid_fields = json_decode($list);
258
-        $json_data['rows'] = $this->form->build_grid($query, $grid_fields);
259
-
260
-        echo json_encode($json_data);
261
-    }
262
-
263
-    function did_list_search() {
264
-        $ajax_search = $this->input->post('ajax_search', 0);
265
-        if ($this->input->post('advance_search', TRUE) == 1) {
266
-            $this->session->set_userdata('advance_search', $this->input->post('advance_search'));
267
-            $action = $this->input->post();
268
-            unset($action['action']);
269
-            unset($action['advance_search']);
270
-            $this->session->set_userdata('did_list_search', $action);
271
-        }
272
-        if (@$ajax_search != 1) {
273
-            redirect(base_url() . 'did/did_list/');
274
-        }
275
-    }
276
-
277
-    function did_list_clearsearchfilter() {
278
-        $this->session->set_userdata('advance_search', 0);
279
-        $this->session->set_userdata('did_search', "");
280
-    }
281
-
282
-
283
-
284
-    function reseller_did($accountid, $accounttype) {
285
-        $json_data = array();
286
-        $account_query = $this->db_model->getSelect("*", "accounts", array("id" => $accountid));
287
-        $account_arr = $account_query->result_array();
288
-
289
-        $this->db->where("reseller_id", $accountid);
290
-        $this->db->select('id');
291
-        $query = $this->db->get('accounts');
292
-        $data = $query->result_array();
293
-
294
-        $count_all = $this->db_model->countQuery("*", "reseller_pricing", array("reseller_id" => $accountid));
295
-        $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
296
-        $json_data = $paging_data["json_paging"];
297
-        $this->db->select('*,note as number', false);
298
-
299
-        $this->db->where("reseller_id", $accountid);
300
-
301
-        if (@$flag) {
302
-            $this->db->order_by('id', 'ASC');
303
-            $this->db->limit($limit, $start);
304
-        }
305
-
306
-        $query = $this->db->get('reseller_pricing');
307
-        //echo $this->db->last_query();exit;
308
-        $did_grid_fields = json_decode($this->did_form->build_did_list_for_reseller($accountid, $accounttype));
309
-        $json_data['rows'] = $this->form->build_grid($query, $did_grid_fields);
310
-
311
-
312
-
313
-        echo json_encode($json_data);
314
-    }
234
+		}
235
+		if ($this->session->userdata['userlevel_logintype'] == '1') {
236
+			$data['grid_fields'] = $this->did_form->build_did_list_for_reseller_login();
237
+			$data['form_search'] = $this->form->build_serach_form($this->did_form->get_search_did_form_for_reseller());
238
+		} else {
239
+			$data['grid_fields'] = $this->did_form->build_did_list_for_admin();
240
+			$data['form_search'] = $this->form->build_serach_form($this->did_form->get_search_did_form());
241
+		}
242
+		$this->load->view('view_did_list', $data);
243
+	}
244
+
245
+	/**
246
+	 * -------Here we write code for controller accounts functions account_list------
247
+	 * Listing of Accounts table data through php function json_encode
248
+	 */
249
+	function did_list_json() {
250
+		$json_data = array();
251
+
252
+		$count_all = $this->did_model->getdid_list(false);
253
+		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
254
+		$json_data = $paging_data["json_paging"];
255
+		$list = $this->session->userdata['userlevel_logintype'] == 1 ? $this->did_form->build_did_list_for_reseller_login() : $this->did_form->build_did_list_for_admin();
256
+		$query = $this->did_model->getdid_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]);
257
+		$grid_fields = json_decode($list);
258
+		$json_data['rows'] = $this->form->build_grid($query, $grid_fields);
259
+
260
+		echo json_encode($json_data);
261
+	}
262
+
263
+	function did_list_search() {
264
+		$ajax_search = $this->input->post('ajax_search', 0);
265
+		if ($this->input->post('advance_search', TRUE) == 1) {
266
+			$this->session->set_userdata('advance_search', $this->input->post('advance_search'));
267
+			$action = $this->input->post();
268
+			unset($action['action']);
269
+			unset($action['advance_search']);
270
+			$this->session->set_userdata('did_list_search', $action);
271
+		}
272
+		if (@$ajax_search != 1) {
273
+			redirect(base_url() . 'did/did_list/');
274
+		}
275
+	}
276
+
277
+	function did_list_clearsearchfilter() {
278
+		$this->session->set_userdata('advance_search', 0);
279
+		$this->session->set_userdata('did_search', "");
280
+	}
281
+
282
+
283
+
284
+	function reseller_did($accountid, $accounttype) {
285
+		$json_data = array();
286
+		$account_query = $this->db_model->getSelect("*", "accounts", array("id" => $accountid));
287
+		$account_arr = $account_query->result_array();
288
+
289
+		$this->db->where("reseller_id", $accountid);
290
+		$this->db->select('id');
291
+		$query = $this->db->get('accounts');
292
+		$data = $query->result_array();
293
+
294
+		$count_all = $this->db_model->countQuery("*", "reseller_pricing", array("reseller_id" => $accountid));
295
+		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
296
+		$json_data = $paging_data["json_paging"];
297
+		$this->db->select('*,note as number', false);
298
+
299
+		$this->db->where("reseller_id", $accountid);
300
+
301
+		if (@$flag) {
302
+			$this->db->order_by('id', 'ASC');
303
+			$this->db->limit($limit, $start);
304
+		}
305
+
306
+		$query = $this->db->get('reseller_pricing');
307
+		//echo $this->db->last_query();exit;
308
+		$did_grid_fields = json_decode($this->did_form->build_did_list_for_reseller($accountid, $accounttype));
309
+		$json_data['rows'] = $this->form->build_grid($query, $did_grid_fields);
310
+
311
+
312
+
313
+		echo json_encode($json_data);
314
+	}
315 315
 /*  ASTPP  3.0 
316 316
  *  Left panel DID Quick search added
317 317
  * 
318 318
  */
319
-    function customer_did($accountid, $accounttype) {
320
-        $json_data = array();
321
-        $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_did'); 
322
-        $account_arr=(array)$this->db->get_where('accounts',array("id"=>$accountid))->first_row();
323
-        $field_name = $accounttype == "reseller" ? "parent_id" : 'accountid';
319
+	function customer_did($accountid, $accounttype) {
320
+		$json_data = array();
321
+		$instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_did'); 
322
+		$account_arr=(array)$this->db->get_where('accounts',array("id"=>$accountid))->first_row();
323
+		$field_name = $accounttype == "reseller" ? "parent_id" : 'accountid';
324 324
 	$like_str=!empty($instant_search) ? 
325
-				    "(a.note like '%$instant_search%'
325
+					"(a.note like '%$instant_search%'
326 326
 					OR  a.init_inc like '%$instant_search%'
327 327
 					OR  a.inc like '%$instant_search%'
328 328
 					OR  a.cost like '%$instant_search%'
@@ -331,32 +331,32 @@  discard block
 block discarded – undo
331 331
 					OR  a.monthlycost like '%$instant_search%'
332 332
 					OR  a.connectcost like '%$instant_search%'
333 333
 					    )" :null;
334
-        if ($account_arr['reseller_id'] != 0) {
335
-	    if(!empty($like_str))
336
-            $this->db->where($like_str);
337
-            if($accounttype=='reseller'){
338
-	      $this->db->where('a.note','b.number',false);
339
-	      $this->db->where('a.reseller_id',$account_arr['id']);
340
-	      $this->db->where('a.parent_id',$account_arr['reseller_id']);
341
-	      $this->db->select('count(a.id) as count');
342
-	      $count_result=(array)$this->db->get('reseller_pricing as a,dids as b')->first_row();
343
-	      $paging_data = $this->form->load_grid_config($count_result['count'], $_GET['rp'], $_GET['page']);
344
-	      $json_data = $paging_data["json_paging"];
345
-	      $this->db->where('a.note','b.number',false);
346
-	      $this->db->where('a.reseller_id',$account_arr['id']);
347
-	      $this->db->where('a.parent_id',$account_arr['reseller_id']);
348
-	      $this->db->select('a . * , b.id, a.reseller_id AS accountid,a.note as number,b.country_id as country_id');
349
-	      $this->db->limit($paging_data["paging"]["page_no"],$paging_data["paging"]["start"]);
350
-	      $query=$this->db->get('reseller_pricing as a,dids as b');
351
-          }else{
352
-	      $count_result=(array)$this->db->query('select count(id) as count from dids where accountid='.$accountid." AND parent_id =".$account_arr['reseller_id'])->first_row();
353
-              $paging_data = $this->form->load_grid_config($count_result['count'], $_GET['rp'], $_GET['page']);
354
-	      $json_data = $paging_data["json_paging"];
355
-              $query=$this->db->query("SELECT a . * ,a.note as number,b.country_id as country_id,b.id FROM reseller_pricing AS a, dids AS b WHERE b.accountid =".$account_arr['id']." AND a.note = b.number AND a.reseller_id =".$account_arr['reseller_id']);
356
-          }
357
-        }else{
358
-                        $like_str=!empty($instant_search) ? 
359
-                                                "(dids.number like '%$instant_search%'
334
+		if ($account_arr['reseller_id'] != 0) {
335
+		if(!empty($like_str))
336
+			$this->db->where($like_str);
337
+			if($accounttype=='reseller'){
338
+		  $this->db->where('a.note','b.number',false);
339
+		  $this->db->where('a.reseller_id',$account_arr['id']);
340
+		  $this->db->where('a.parent_id',$account_arr['reseller_id']);
341
+		  $this->db->select('count(a.id) as count');
342
+		  $count_result=(array)$this->db->get('reseller_pricing as a,dids as b')->first_row();
343
+		  $paging_data = $this->form->load_grid_config($count_result['count'], $_GET['rp'], $_GET['page']);
344
+		  $json_data = $paging_data["json_paging"];
345
+		  $this->db->where('a.note','b.number',false);
346
+		  $this->db->where('a.reseller_id',$account_arr['id']);
347
+		  $this->db->where('a.parent_id',$account_arr['reseller_id']);
348
+		  $this->db->select('a . * , b.id, a.reseller_id AS accountid,a.note as number,b.country_id as country_id');
349
+		  $this->db->limit($paging_data["paging"]["page_no"],$paging_data["paging"]["start"]);
350
+		  $query=$this->db->get('reseller_pricing as a,dids as b');
351
+		  }else{
352
+		  $count_result=(array)$this->db->query('select count(id) as count from dids where accountid='.$accountid." AND parent_id =".$account_arr['reseller_id'])->first_row();
353
+			  $paging_data = $this->form->load_grid_config($count_result['count'], $_GET['rp'], $_GET['page']);
354
+		  $json_data = $paging_data["json_paging"];
355
+			  $query=$this->db->query("SELECT a . * ,a.note as number,b.country_id as country_id,b.id FROM reseller_pricing AS a, dids AS b WHERE b.accountid =".$account_arr['id']." AND a.note = b.number AND a.reseller_id =".$account_arr['reseller_id']);
356
+		  }
357
+		}else{
358
+						$like_str=!empty($instant_search) ? 
359
+												"(dids.number like '%$instant_search%'
360 360
                                                     OR dids.inc like '%$instant_search%'
361 361
                                                     OR dids.cost like '%$instant_search%'
362 362
                                                     OR dids.includedseconds like '%$instant_search%'
@@ -364,91 +364,91 @@  discard block
 block discarded – undo
364 364
                                                     OR dids.monthlycost like '%$instant_search%'
365 365
                                                     OR dids.connectcost like '%$instant_search%'
366 366
                                                         )" :null;
367
-            if(!empty($like_str))
368
-            $this->db->where($like_str);
369
-            $where = array($field_name => $accountid);
370
-            $count_all = $this->db_model->countQuery("*", "dids", $where);
371
-            $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
372
-            $json_data = $paging_data["json_paging"];
373
-            if(!empty($like_str))
374
-            $this->db->where($like_str);
375
-            $query = $this->db_model->select("*", "dids", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]);
376
-        }
377
-        $did_grid_fields = json_decode($this->did_form->build_did_list_for_customer($accountid, $accounttype));
378
-        $json_data['rows'] = $this->form->build_grid($query, $did_grid_fields);
379
-        echo json_encode($json_data);
380
-    }
381
-    function did_delete_multiple() {
382
-        $ids = $this->input->post("selected_ids", true);
383
-        $where = "id IN ($ids)";
384
-        $this->db->where($where);
385
-        $this->db->select("group_concat(concat('''',number,'''')) as number",false);
386
-        $dids_result=(array)$this->db->get('dids')->first_row();
387
-        $notes_where="note IN (".$dids_result['number'].")";
388
-        $this->db->where($notes_where);
389
-        $this->db->delete('reseller_pricing');
390
-        $this->db->where($where);
391
-        echo $this->db->delete("dids");
392
-    }
393
-
394
-    /**
395
-     * -------Here we write code for controller did functions manage------
396
-     * @action: Add, Edit, Delete, List DID
397
-     * @id: DID number
398
-     */
399
-    function did_reseller_edit($action = false, $id = false) {
400
-        $data['page_title'] = 'Edit DID ';
401
-        $accountinfo=$this->session->userdata('accountinfo');
402
-        if ($action == 'edit') {
403
-            if (($this->input->post())) {
404
-                $post = $this->input->post();
405
-                /*
367
+			if(!empty($like_str))
368
+			$this->db->where($like_str);
369
+			$where = array($field_name => $accountid);
370
+			$count_all = $this->db_model->countQuery("*", "dids", $where);
371
+			$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
372
+			$json_data = $paging_data["json_paging"];
373
+			if(!empty($like_str))
374
+			$this->db->where($like_str);
375
+			$query = $this->db_model->select("*", "dids", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]);
376
+		}
377
+		$did_grid_fields = json_decode($this->did_form->build_did_list_for_customer($accountid, $accounttype));
378
+		$json_data['rows'] = $this->form->build_grid($query, $did_grid_fields);
379
+		echo json_encode($json_data);
380
+	}
381
+	function did_delete_multiple() {
382
+		$ids = $this->input->post("selected_ids", true);
383
+		$where = "id IN ($ids)";
384
+		$this->db->where($where);
385
+		$this->db->select("group_concat(concat('''',number,'''')) as number",false);
386
+		$dids_result=(array)$this->db->get('dids')->first_row();
387
+		$notes_where="note IN (".$dids_result['number'].")";
388
+		$this->db->where($notes_where);
389
+		$this->db->delete('reseller_pricing');
390
+		$this->db->where($where);
391
+		echo $this->db->delete("dids");
392
+	}
393
+
394
+	/**
395
+	 * -------Here we write code for controller did functions manage------
396
+	 * @action: Add, Edit, Delete, List DID
397
+	 * @id: DID number
398
+	 */
399
+	function did_reseller_edit($action = false, $id = false) {
400
+		$data['page_title'] = 'Edit DID ';
401
+		$accountinfo=$this->session->userdata('accountinfo');
402
+		if ($action == 'edit') {
403
+			if (($this->input->post())) {
404
+				$post = $this->input->post();
405
+				/*
406 406
                   ASTPP  3.0 last modified date update
407 407
                  */
408
-                $post['last_modified_date'] = gmdate('Y-m-d H:i:s');
409
-                /*                 * ***************************************************** */
410
-                unset($post['action']);
411
-                $post['setup'] = $this->common_model->add_calculate_currency($post['setup'], '', '', false, false);
412
-                $post['monthlycost'] = $this->common_model->add_calculate_currency($post['monthlycost'], '', '', false, false);
413
-                $post['connectcost'] = $this->common_model->add_calculate_currency($post['connectcost'], '', '', false, false);
414
-                $post['cost'] = $this->common_model->add_calculate_currency($post['cost'], '', '', false, false);
415
-                $this->db->where(array('note' => $post['note'], "reseller_id" => $accountinfo['id']));
416
-                $this->db->update("reseller_pricing", $post);
417
-                $where_update_did = array('extensions' => $post['extensions'], 'call_type' => $post['call_type']);
418
-                $this->db->where(array('note' => $post['note']));
419
-                $this->db->update("reseller_pricing", $where_update_did);
420
-                $where = array('number' => $post['note']);
421
-                $this->db->where($where);
422
-                $this->db->update("dids", $where_update_did);
423
-                echo json_encode(array("SUCCESS" => " DID Updated Successfully!!"));
424
-                exit;
425
-            } else {
426
-                if ($this->session->userdata('logintype') == 1) {
427
-                    $accountinfo = $this->did_model->get_account($accountinfo['number']);
428
-                    $reseller_did = $this->db_model->getSelect("*", "reseller_pricing", array('id' => $id));
429
-                    $reseller_didinfo = (array)$reseller_did->first_row();
430
-                    if (!empty($reseller_didinfo)) {
431
-                        $reseller_didinfo['setup'] = $this->common_model->to_calculate_currency($reseller_didinfo['setup'], '', '', true, false);
432
-                        $reseller_didinfo['monthlycost'] = $this->common_model->to_calculate_currency($reseller_didinfo['monthlycost'], '', '', true, false);
433
-                        $reseller_didinfo['connectcost'] = $this->common_model->to_calculate_currency($reseller_didinfo['connectcost'], '', '', true, false);
434
-                        $reseller_didinfo['cost'] = $this->common_model->to_calculate_currency($reseller_didinfo['cost'], '', '', true, false);
435
-                        $data['did'] = $reseller_didinfo['note'];
436
-                    }
437
-                    $data['reseller_didinfo'] = $reseller_didinfo;
438
-                    $data['accountinfo'] = $accountinfo;
439
-                    $this->load->view('view_did_manage_reseller_add', $data);
440
-                }
441
-            }
442
-        }
443
-        if ($action == 'delete') {
444
-	    	    $this->db->where('id',$id);
445
-	    $this->db->select('note');
446
-            $reseller_pricing=(array)$this->db->get('reseller_pricing')->first_row();
447
-            $did_number=$reseller_pricing['note'];
448
-            $did_info=(array)$this->db->get_where('dids',array('number'=>$did_number))->first_row();
449
-            $query="select count(id) as count from reseller_pricing where id >= (select id from reseller_pricing where note =$did_number AND parent_id =".$accountinfo['reseller_id']." AND reseller_id =".$accountinfo['id'].") AND note= $did_number order by id desc";
450
-	    $result=(array)$this->db->query($query)->first_row();
451
-	    if($result['count'] > 0){
408
+				$post['last_modified_date'] = gmdate('Y-m-d H:i:s');
409
+				/*                 * ***************************************************** */
410
+				unset($post['action']);
411
+				$post['setup'] = $this->common_model->add_calculate_currency($post['setup'], '', '', false, false);
412
+				$post['monthlycost'] = $this->common_model->add_calculate_currency($post['monthlycost'], '', '', false, false);
413
+				$post['connectcost'] = $this->common_model->add_calculate_currency($post['connectcost'], '', '', false, false);
414
+				$post['cost'] = $this->common_model->add_calculate_currency($post['cost'], '', '', false, false);
415
+				$this->db->where(array('note' => $post['note'], "reseller_id" => $accountinfo['id']));
416
+				$this->db->update("reseller_pricing", $post);
417
+				$where_update_did = array('extensions' => $post['extensions'], 'call_type' => $post['call_type']);
418
+				$this->db->where(array('note' => $post['note']));
419
+				$this->db->update("reseller_pricing", $where_update_did);
420
+				$where = array('number' => $post['note']);
421
+				$this->db->where($where);
422
+				$this->db->update("dids", $where_update_did);
423
+				echo json_encode(array("SUCCESS" => " DID Updated Successfully!!"));
424
+				exit;
425
+			} else {
426
+				if ($this->session->userdata('logintype') == 1) {
427
+					$accountinfo = $this->did_model->get_account($accountinfo['number']);
428
+					$reseller_did = $this->db_model->getSelect("*", "reseller_pricing", array('id' => $id));
429
+					$reseller_didinfo = (array)$reseller_did->first_row();
430
+					if (!empty($reseller_didinfo)) {
431
+						$reseller_didinfo['setup'] = $this->common_model->to_calculate_currency($reseller_didinfo['setup'], '', '', true, false);
432
+						$reseller_didinfo['monthlycost'] = $this->common_model->to_calculate_currency($reseller_didinfo['monthlycost'], '', '', true, false);
433
+						$reseller_didinfo['connectcost'] = $this->common_model->to_calculate_currency($reseller_didinfo['connectcost'], '', '', true, false);
434
+						$reseller_didinfo['cost'] = $this->common_model->to_calculate_currency($reseller_didinfo['cost'], '', '', true, false);
435
+						$data['did'] = $reseller_didinfo['note'];
436
+					}
437
+					$data['reseller_didinfo'] = $reseller_didinfo;
438
+					$data['accountinfo'] = $accountinfo;
439
+					$this->load->view('view_did_manage_reseller_add', $data);
440
+				}
441
+			}
442
+		}
443
+		if ($action == 'delete') {
444
+				$this->db->where('id',$id);
445
+		$this->db->select('note');
446
+			$reseller_pricing=(array)$this->db->get('reseller_pricing')->first_row();
447
+			$did_number=$reseller_pricing['note'];
448
+			$did_info=(array)$this->db->get_where('dids',array('number'=>$did_number))->first_row();
449
+			$query="select count(id) as count from reseller_pricing where id >= (select id from reseller_pricing where note =$did_number AND parent_id =".$accountinfo['reseller_id']." AND reseller_id =".$accountinfo['id'].") AND note= $did_number order by id desc";
450
+		$result=(array)$this->db->query($query)->first_row();
451
+		if($result['count'] > 0){
452 452
 		$str=$this->common->get_parent_info($did_info['parent_id'],$accountinfo['id']);
453 453
 		$str=rtrim($str,",");
454 454
 		$account_result=(array)$this->db->get_where('accounts',"id IN (".$str.")")->result_array();
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 		  $acc_row['did_number']=$did_info['number'];
457 457
 		  $this->common->mail_to_users('email_remove_did', $acc_row);
458 458
 		}
459
-	    	$reseller_ids=$this->common->get_subreseller_info($accountinfo['id']);
459
+			$reseller_ids=$this->common->get_subreseller_info($accountinfo['id']);
460 460
 		$reseller_ids=rtrim($reseller_ids,",");
461 461
 		$where="parent_id IN ($reseller_ids)";
462 462
 		$this->db->where('note',$did_info['number']);
@@ -464,188 +464,188 @@  discard block
 block discarded – undo
464 464
 		$this->db->where('reseller_id',$accountinfo['id']);
465 465
 		$this->db->where('note',$did_info['number']);
466 466
 		$this->db->delete('reseller_pricing');  
467
-	    }
468
-	    $this->db->where('number',$did_number);
469
-	    $this->db->select('accountid');
470
-	    $did_array=(array)$this->db->get('dids')->first_row();
471
-	    if($did_array['accountid'] > 0){
472
-	     $customer_info=(array)$this->db->get_where('accounts',array('id'=>$did_array['accountid']))->first_row();
473
-	     $customer_info['did_number']=$did_number;
474
-	     $this->common->mail_to_users('email_remove_did', $customer_info);
475
-	    }
476
-	    $did_array=array("accountid"=>0,"parent_id"=>$accountinfo['reseller_id'], "assign_date" => "0000-00-00 00:00:00", "charge_upto" => "0000-00-00 00:00:00");
477
-	    $this->db->where('number',$did_number);
478
-	    $this->db->update('dids',$did_array);
479
-            $this->session->set_flashdata('astpp_notification', 'DID Removed Successfully!');
480
-            redirect(base_url() . 'did/did_list/');
481
-        }
482
-    }
483
-
484
-    function did_reseller_purchase() {
485
-        //Get account information from session.
486
-        $accountinfo = $this->session->userdata('accountinfo');
487
-        $where = array('id' => $accountinfo['id']);
488
-        $account = $this->db_model->getSelect("*", "accounts", $where);
489
-        $currency_name=$this->common->get_field_name('currency',"currency",array('id'=>$accountinfo['currency_id']));
490
-        $accountinfo= (array)$account->first_row();
491
-        if (($this->input->post())) {
492
-            $post = $this->input->post();
493
-            if (isset($post['free_did_list']) && $post['free_did_list'] != '') {
494
-                // For deduction of admin price to reseller
495
-                $didinfo = $this->did_model->get_did_by_number($post['free_did_list']);
496
-                if($accountinfo['reseller_id'] > 0 ){
497
-                $reseller_pricing_query = $this->db_model->getSelect("call_type,setup,extensions,monthlycost,connectcost,includedseconds,cost,inc", "reseller_pricing", array("note" => $didinfo['number'],'reseller_id'=>$accountinfo['reseller_id']));
498
-                   $reseller_pricing_result = (array)$reseller_pricing_query->first_row();
499
-                   $didinfo['call_type']=$reseller_pricing_result['call_type'];
500
-                   $didinfo['extensions']=$reseller_pricing_result['extensions'];
501
-                   $didinfo['setup']=$reseller_pricing_result['setup'];
502
-                   $didinfo['monthlycost']=$reseller_pricing_result['monthlycost'];
503
-                   $didinfo['connectcost']=$reseller_pricing_result['connectcost'];
504
-                   $didinfo['includedseconds']=$reseller_pricing_result['includedseconds'];
505
-                   $didinfo['cost']=$reseller_pricing_result['cost'];
506
-                   $didinfo['inc']=$reseller_pricing_result['inc'];
507
-                }
508
-                $available_bal = $this->db_model->get_available_bal($accountinfo);
509
-                 $accountinfo['did_number'] = $didinfo['number'];
467
+		}
468
+		$this->db->where('number',$did_number);
469
+		$this->db->select('accountid');
470
+		$did_array=(array)$this->db->get('dids')->first_row();
471
+		if($did_array['accountid'] > 0){
472
+		 $customer_info=(array)$this->db->get_where('accounts',array('id'=>$did_array['accountid']))->first_row();
473
+		 $customer_info['did_number']=$did_number;
474
+		 $this->common->mail_to_users('email_remove_did', $customer_info);
475
+		}
476
+		$did_array=array("accountid"=>0,"parent_id"=>$accountinfo['reseller_id'], "assign_date" => "0000-00-00 00:00:00", "charge_upto" => "0000-00-00 00:00:00");
477
+		$this->db->where('number',$did_number);
478
+		$this->db->update('dids',$did_array);
479
+			$this->session->set_flashdata('astpp_notification', 'DID Removed Successfully!');
480
+			redirect(base_url() . 'did/did_list/');
481
+		}
482
+	}
483
+
484
+	function did_reseller_purchase() {
485
+		//Get account information from session.
486
+		$accountinfo = $this->session->userdata('accountinfo');
487
+		$where = array('id' => $accountinfo['id']);
488
+		$account = $this->db_model->getSelect("*", "accounts", $where);
489
+		$currency_name=$this->common->get_field_name('currency',"currency",array('id'=>$accountinfo['currency_id']));
490
+		$accountinfo= (array)$account->first_row();
491
+		if (($this->input->post())) {
492
+			$post = $this->input->post();
493
+			if (isset($post['free_did_list']) && $post['free_did_list'] != '') {
494
+				// For deduction of admin price to reseller
495
+				$didinfo = $this->did_model->get_did_by_number($post['free_did_list']);
496
+				if($accountinfo['reseller_id'] > 0 ){
497
+				$reseller_pricing_query = $this->db_model->getSelect("call_type,setup,extensions,monthlycost,connectcost,includedseconds,cost,inc", "reseller_pricing", array("note" => $didinfo['number'],'reseller_id'=>$accountinfo['reseller_id']));
498
+				   $reseller_pricing_result = (array)$reseller_pricing_query->first_row();
499
+				   $didinfo['call_type']=$reseller_pricing_result['call_type'];
500
+				   $didinfo['extensions']=$reseller_pricing_result['extensions'];
501
+				   $didinfo['setup']=$reseller_pricing_result['setup'];
502
+				   $didinfo['monthlycost']=$reseller_pricing_result['monthlycost'];
503
+				   $didinfo['connectcost']=$reseller_pricing_result['connectcost'];
504
+				   $didinfo['includedseconds']=$reseller_pricing_result['includedseconds'];
505
+				   $didinfo['cost']=$reseller_pricing_result['cost'];
506
+				   $didinfo['inc']=$reseller_pricing_result['inc'];
507
+				}
508
+				$available_bal = $this->db_model->get_available_bal($accountinfo);
509
+				 $accountinfo['did_number'] = $didinfo['number'];
510 510
 		 $accountinfo['did_country_id'] = $didinfo['country_id'];
511 511
 		 $accountinfo['did_setup'] = $this->common_model->calculate_currency($didinfo['setup'],'',$currency_name,true,true);
512 512
 		 $accountinfo['did_monthlycost'] = $this->common_model->calculate_currency($didinfo['monthlycost'],'',$currency_name,true,true);
513 513
 		 $accountinfo['did_maxchannels'] = $didinfo['maxchannels'];
514
-                if ($available_bal >= $didinfo["setup"]) {
515
-                    $available_bal = $this->db_model->update_balance($didinfo['setup'], $accountinfo['id'], "debit");
516
-                    $this->db_model->update("dids", array('parent_id' => $accountinfo['id'],"assign_date"=>gmdate("Y-m-d H:i:s")), array("id" => $didinfo['id']));
517
-                    $this->did_model->insert_reseller_pricing($accountinfo, $didinfo);
518
-                    $this->common->add_invoice_details($accountinfo,"DIDCHRG",$didinfo['setup'],$didinfo['number']);
519
-                    $this->common->mail_to_users('email_add_did', $accountinfo,"",$didinfo['number']);
520
-                    $this->session->set_flashdata('astpp_errormsg', 'DID Purchased Successfully.');
521
-                } else {
522
-                    $this->session->set_flashdata('astpp_notification', 'Insuffiecient fund to purchase this did');
523
-                }
524
-            } else {
525
-                $this->session->set_flashdata('astpp_notification', 'Please Select DID.');
526
-            }
527
-        }
528
-        redirect(base_url() . 'did/did_list/');
529
-        exit;
530
-    }
531
-
532
-    function add_invoice_data_user($accountid, $charge_type, $description, $credit) {
533
-        $insert_array = array('accountid' => $accountid,
534
-            'charge_type' => $charge_type,
535
-            'description' => $description,
536
-            'credit' => $credit,
537
-            'charge_id' => '0',
538
-            'package_id' => '0'
539
-        );
540
-
541
-        $this->db->insert('invoice_item', $insert_array);
542
-        $this->load->module('invoices/invoices');
543
-        $this->invoices->invoices->generate_receipt($accountid, $credit);
544
-
545
-        return true;
546
-    }
547
-
548
-    function did_download_sample_file($file_name) {
549
-        $this->load->helper('download');
550
-        $full_path = base_url() . "assets/Rates_File/" . $file_name . ".csv";
551
-        $arrContextOptions=array(
514
+				if ($available_bal >= $didinfo["setup"]) {
515
+					$available_bal = $this->db_model->update_balance($didinfo['setup'], $accountinfo['id'], "debit");
516
+					$this->db_model->update("dids", array('parent_id' => $accountinfo['id'],"assign_date"=>gmdate("Y-m-d H:i:s")), array("id" => $didinfo['id']));
517
+					$this->did_model->insert_reseller_pricing($accountinfo, $didinfo);
518
+					$this->common->add_invoice_details($accountinfo,"DIDCHRG",$didinfo['setup'],$didinfo['number']);
519
+					$this->common->mail_to_users('email_add_did', $accountinfo,"",$didinfo['number']);
520
+					$this->session->set_flashdata('astpp_errormsg', 'DID Purchased Successfully.');
521
+				} else {
522
+					$this->session->set_flashdata('astpp_notification', 'Insuffiecient fund to purchase this did');
523
+				}
524
+			} else {
525
+				$this->session->set_flashdata('astpp_notification', 'Please Select DID.');
526
+			}
527
+		}
528
+		redirect(base_url() . 'did/did_list/');
529
+		exit;
530
+	}
531
+
532
+	function add_invoice_data_user($accountid, $charge_type, $description, $credit) {
533
+		$insert_array = array('accountid' => $accountid,
534
+			'charge_type' => $charge_type,
535
+			'description' => $description,
536
+			'credit' => $credit,
537
+			'charge_id' => '0',
538
+			'package_id' => '0'
539
+		);
540
+
541
+		$this->db->insert('invoice_item', $insert_array);
542
+		$this->load->module('invoices/invoices');
543
+		$this->invoices->invoices->generate_receipt($accountid, $credit);
544
+
545
+		return true;
546
+	}
547
+
548
+	function did_download_sample_file($file_name) {
549
+		$this->load->helper('download');
550
+		$full_path = base_url() . "assets/Rates_File/" . $file_name . ".csv";
551
+		$arrContextOptions=array(
552 552
 			"ssl"=>array(
553 553
 			"verify_peer"=>false,
554 554
 			"verify_peer_name"=>false,
555 555
 			),
556 556
 		);  
557
-        $file = file_get_contents($full_path, false, stream_context_create($arrContextOptions));
558
-        force_download("samplefile.csv", $file);
559
-    }
560
-    /* -------Here we write code for controller did functions did_import------
557
+		$file = file_get_contents($full_path, false, stream_context_create($arrContextOptions));
558
+		force_download("samplefile.csv", $file);
559
+	}
560
+	/* -------Here we write code for controller did functions did_import------
561 561
      * @Purpose this function check if account number exist or not then remove from database.
562 562
      * @params $account_number: Account Number
563 563
      * @return Return Appropreate message If Account Delete or not.
564 564
      */
565
-    function did_import() {
566
-        $data['page_title'] = 'Import DIDs';
567
-        $this->session->set_userdata('import_did_rate_csv', "");
568
-        $error_data = $this->session->userdata('import_did_csv_error');
569
-        $full_path = $this->config->item('rates-file-path');
570
-        if (file_exists($full_path . $error_data) && $error_data != "") {
571
-            unlink($full_path . $error_data);
572
-            $this->session->set_userdata('import_did_csv_error', "");
573
-        }
574
-        $accountinfo=$this->session->userdata('accountinfo');
575
-        $this->db->where('id',$accountinfo['currency_id']);
576
-        $this->db->select('currency');
577
-        $currency_info=(array)$this->db->get('currency')->first_row();
578
-        $data['fields']="DID,Country,Account,Per Minute Cost(".$currency_info['currency']."),Initial Increment,Increment,Setup Fee(".$currency_info['currency']."),Monthly Fee(".$currency_info['currency']."),Call Type,Destination,Status";
579
-        $this->load->view('view_import_did', $data);
580
-    }
581
-
582
-    function did_preview_file() {
583
-        $data['page_title'] = 'Import DIDs';
584
-        $config_did_array = $this->config->item('DID-rates-field');
585
-        $accountinfo=$this->session->userdata('accountinfo');
586
-        $this->db->where('id',$accountinfo['currency_id']);
587
-        $this->db->select('currency');
588
-        $currency_info=(array)$this->db->get('currency')->first_row();
589
-        foreach($config_did_array as $key=>$value){
590
-         $key = str_replace('CURRENCY', $currency_info['currency'], $key);
591
-         $did_fields_array[$key]=$value;
592
-        }
593
-        $check_header = $this->input->post('check_header', true);
594
-        $invalid_flag = false;
595
-        if (isset($_FILES['didimport']['name']) && $_FILES['didimport']['name'] != "") {
596
-            list($txt, $ext) = explode(".", $_FILES['didimport']['name']);
597
-            if ($ext == "csv" && $_FILES["didimport"]['size'] > 0) {
598
-                $error = $_FILES['didimport']['error'];
599
-                if ($error == 0) {
600
-                    $uploadedFile = $_FILES["didimport"]["tmp_name"];
601
-                    $full_path = $this->config->item('rates-file-path');
602
-                    $actual_file_name = "ASTPP-DIDs-" . date("Y-m-d H:i:s") . "." . $ext;
603
-                    if (move_uploaded_file($uploadedFile, $full_path . $actual_file_name)) {
604
-                        $data['page_title'] = 'Import DIDs Preview';
605
-                        $data['csv_tmp_data'] = $this->csvreader->parse_file($full_path . $actual_file_name, $did_fields_array, $check_header);
606
-                        $data['provider_id'] = $_POST['provider_id'];
607
-                        $data['check_header'] = $check_header;
608
-                        $this->session->set_userdata('import_did_rate_csv', $actual_file_name);
609
-                    } else {
610
-                        $data['error'] = "File Uploading Fail Please Try Again";
611
-                    }
612
-                }
613
-            } else {
614
-                $data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)";
615
-            }
616
-        } else {
617
-            $invalid_flag = true;
618
-        }
619
-        if ($invalid_flag) {
620
-            $str = '';
621
-            if (empty($_FILES['didimport']['name'])) {
622
-                $str.= '<br/>Please Select  File.';
623
-            }
624
-            $data['error'] = $str;
625
-        }
626
-        $this->load->view('view_import_did', $data);
627
-    }
628
-
629
-    function did_import_file($provider_id, $check_header = false) {
630
-        $new_final_arr = array();
631
-        $invalid_array = array();
632
-        $new_final_arr_key = $this->config->item('DID-rates-field');
633
-        $accountinfo=$this->session->userdata('accountinfo');
634
-        $reseller_id = $accountinfo['type']==1 ? $accountinfo['id']: 0;
565
+	function did_import() {
566
+		$data['page_title'] = 'Import DIDs';
567
+		$this->session->set_userdata('import_did_rate_csv', "");
568
+		$error_data = $this->session->userdata('import_did_csv_error');
569
+		$full_path = $this->config->item('rates-file-path');
570
+		if (file_exists($full_path . $error_data) && $error_data != "") {
571
+			unlink($full_path . $error_data);
572
+			$this->session->set_userdata('import_did_csv_error', "");
573
+		}
574
+		$accountinfo=$this->session->userdata('accountinfo');
575
+		$this->db->where('id',$accountinfo['currency_id']);
576
+		$this->db->select('currency');
577
+		$currency_info=(array)$this->db->get('currency')->first_row();
578
+		$data['fields']="DID,Country,Account,Per Minute Cost(".$currency_info['currency']."),Initial Increment,Increment,Setup Fee(".$currency_info['currency']."),Monthly Fee(".$currency_info['currency']."),Call Type,Destination,Status";
579
+		$this->load->view('view_import_did', $data);
580
+	}
581
+
582
+	function did_preview_file() {
583
+		$data['page_title'] = 'Import DIDs';
584
+		$config_did_array = $this->config->item('DID-rates-field');
585
+		$accountinfo=$this->session->userdata('accountinfo');
586
+		$this->db->where('id',$accountinfo['currency_id']);
587
+		$this->db->select('currency');
588
+		$currency_info=(array)$this->db->get('currency')->first_row();
589
+		foreach($config_did_array as $key=>$value){
590
+		 $key = str_replace('CURRENCY', $currency_info['currency'], $key);
591
+		 $did_fields_array[$key]=$value;
592
+		}
593
+		$check_header = $this->input->post('check_header', true);
594
+		$invalid_flag = false;
595
+		if (isset($_FILES['didimport']['name']) && $_FILES['didimport']['name'] != "") {
596
+			list($txt, $ext) = explode(".", $_FILES['didimport']['name']);
597
+			if ($ext == "csv" && $_FILES["didimport"]['size'] > 0) {
598
+				$error = $_FILES['didimport']['error'];
599
+				if ($error == 0) {
600
+					$uploadedFile = $_FILES["didimport"]["tmp_name"];
601
+					$full_path = $this->config->item('rates-file-path');
602
+					$actual_file_name = "ASTPP-DIDs-" . date("Y-m-d H:i:s") . "." . $ext;
603
+					if (move_uploaded_file($uploadedFile, $full_path . $actual_file_name)) {
604
+						$data['page_title'] = 'Import DIDs Preview';
605
+						$data['csv_tmp_data'] = $this->csvreader->parse_file($full_path . $actual_file_name, $did_fields_array, $check_header);
606
+						$data['provider_id'] = $_POST['provider_id'];
607
+						$data['check_header'] = $check_header;
608
+						$this->session->set_userdata('import_did_rate_csv', $actual_file_name);
609
+					} else {
610
+						$data['error'] = "File Uploading Fail Please Try Again";
611
+					}
612
+				}
613
+			} else {
614
+				$data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)";
615
+			}
616
+		} else {
617
+			$invalid_flag = true;
618
+		}
619
+		if ($invalid_flag) {
620
+			$str = '';
621
+			if (empty($_FILES['didimport']['name'])) {
622
+				$str.= '<br/>Please Select  File.';
623
+			}
624
+			$data['error'] = $str;
625
+		}
626
+		$this->load->view('view_import_did', $data);
627
+	}
628
+
629
+	function did_import_file($provider_id, $check_header = false) {
630
+		$new_final_arr = array();
631
+		$invalid_array = array();
632
+		$new_final_arr_key = $this->config->item('DID-rates-field');
633
+		$accountinfo=$this->session->userdata('accountinfo');
634
+		$reseller_id = $accountinfo['type']==1 ? $accountinfo['id']: 0;
635 635
 	
636
-        $full_path = $this->config->item('rates-file-path');
637
-        $did_file_name = $this->session->userdata('import_did_rate_csv');
638
-        $csv_tmp_data = $this->csvreader->parse_file($full_path . $did_file_name, $new_final_arr_key, $check_header);
639
-        $flag = false;
640
-        $i = 0;
641
-        $number_arr = array();
642
-        $reseller_array=array();
643
-        $final_reseller_array=array();
644
-        foreach ($csv_tmp_data as $key => $csv_data) {
636
+		$full_path = $this->config->item('rates-file-path');
637
+		$did_file_name = $this->session->userdata('import_did_rate_csv');
638
+		$csv_tmp_data = $this->csvreader->parse_file($full_path . $did_file_name, $new_final_arr_key, $check_header);
639
+		$flag = false;
640
+		$i = 0;
641
+		$number_arr = array();
642
+		$reseller_array=array();
643
+		$final_reseller_array=array();
644
+		foreach ($csv_tmp_data as $key => $csv_data) {
645 645
         
646
-            if (isset($csv_data['number']) && $csv_data['number'] != '' && $i != 0) {
647
-                $str = null;
648
-                if(isset($csv_data['call_type'])){
646
+			if (isset($csv_data['number']) && $csv_data['number'] != '' && $i != 0) {
647
+				$str = null;
648
+				if(isset($csv_data['call_type'])){
649 649
 					if(strtolower($csv_data['call_type']) == 'sip-did'){
650 650
 						$call_type = '3';
651 651
 					}
@@ -661,166 +661,166 @@  discard block
 block discarded – undo
661 661
 				}else{
662 662
 					$call_type = '0';
663 663
 				}
664
-                $csv_data['accountid'] = isset($csv_data['accountid']) ? $csv_data['accountid'] : 0;
665
-                $csv_data['country_id'] = isset($csv_data['country_id']) ? $csv_data['country_id'] : 0;
666
-                //$csv_data['call_type'] = isset($csv_data['call_type']) && (strtolower($csv_data['call_type']) == 'local' || strtolower($csv_data['call_type']) == 'pstn' || strtolower($csv_data['call_type']) == 'other' ) ? $this->common->get_custom_call_type(strtoupper($csv_data['call_type'])) : 0;
664
+				$csv_data['accountid'] = isset($csv_data['accountid']) ? $csv_data['accountid'] : 0;
665
+				$csv_data['country_id'] = isset($csv_data['country_id']) ? $csv_data['country_id'] : 0;
666
+				//$csv_data['call_type'] = isset($csv_data['call_type']) && (strtolower($csv_data['call_type']) == 'local' || strtolower($csv_data['call_type']) == 'pstn' || strtolower($csv_data['call_type']) == 'other' ) ? $this->common->get_custom_call_type(strtoupper($csv_data['call_type'])) : 0;
667 667
 				$csv_data['call_type'] = $call_type;
668
-                $csv_data['extensions'] = isset($csv_data['extensions']) ? $csv_data['extensions'] : '';
669
-                $csv_data['includedseconds'] = isset($csv_data['includedseconds']) ? $csv_data['includedseconds'] : 0;
670
-                $csv_data['cost'] = !empty($csv_data['cost']) && is_numeric($csv_data['cost']) && $csv_data['cost'] ? $csv_data['cost'] : 0;
671
-                $csv_data['setup'] = !empty($csv_data['setup']) && is_numeric($csv_data['setup']) && $csv_data['setup'] > 0 ? $csv_data['setup'] : 0;
672
-                $csv_data['monthlycost'] = !empty($csv_data['monthlycost']) && is_numeric($csv_data['monthlycost']) && $csv_data['monthlycost'] > 0 ? $csv_data['monthlycost'] : 0;
673
-                $csv_data['connectcost'] = !empty($csv_data['connectcost']) && is_numeric($csv_data['connectcost']) && $csv_data['connectcost'] > 0 ? $csv_data['connectcost'] : 0;
674
-                $csv_data['inc'] = isset($csv_data['inc']) ? $csv_data['inc'] : 0;
675
-                $str = $this->data_validate($csv_data);
676
-                if ($str != "") {
677
-                    $invalid_array[$i] = $csv_data;
678
-                    $invalid_array[$i]['error'] = $str;
679
-                } else {
680
-                    if (!in_array($csv_data['number'], $number_arr)) {
681
-                        $number_count = $this->db_model->countQuery('id', 'dids', array('number' => $csv_data['number']));
682
-                        if ($number_count > 0) {
683
-                            $invalid_array[$i] = $csv_data;
684
-                            $invalid_array[$i]['error'] = 'Duplicate DID found from database';
685
-                        } else {
686
-                            if($csv_data['accountid'] > 0 && $csv_data['setup'] > 0){
668
+				$csv_data['extensions'] = isset($csv_data['extensions']) ? $csv_data['extensions'] : '';
669
+				$csv_data['includedseconds'] = isset($csv_data['includedseconds']) ? $csv_data['includedseconds'] : 0;
670
+				$csv_data['cost'] = !empty($csv_data['cost']) && is_numeric($csv_data['cost']) && $csv_data['cost'] ? $csv_data['cost'] : 0;
671
+				$csv_data['setup'] = !empty($csv_data['setup']) && is_numeric($csv_data['setup']) && $csv_data['setup'] > 0 ? $csv_data['setup'] : 0;
672
+				$csv_data['monthlycost'] = !empty($csv_data['monthlycost']) && is_numeric($csv_data['monthlycost']) && $csv_data['monthlycost'] > 0 ? $csv_data['monthlycost'] : 0;
673
+				$csv_data['connectcost'] = !empty($csv_data['connectcost']) && is_numeric($csv_data['connectcost']) && $csv_data['connectcost'] > 0 ? $csv_data['connectcost'] : 0;
674
+				$csv_data['inc'] = isset($csv_data['inc']) ? $csv_data['inc'] : 0;
675
+				$str = $this->data_validate($csv_data);
676
+				if ($str != "") {
677
+					$invalid_array[$i] = $csv_data;
678
+					$invalid_array[$i]['error'] = $str;
679
+				} else {
680
+					if (!in_array($csv_data['number'], $number_arr)) {
681
+						$number_count = $this->db_model->countQuery('id', 'dids', array('number' => $csv_data['number']));
682
+						if ($number_count > 0) {
683
+							$invalid_array[$i] = $csv_data;
684
+							$invalid_array[$i]['error'] = 'Duplicate DID found from database';
685
+						} else {
686
+							if($csv_data['accountid'] > 0 && $csv_data['setup'] > 0){
687 687
 						  $this->db->where('type IN(0,1,3)');
688 688
 						  $this->db->where('reseller_id',0);
689 689
 						  $this->db->where('deleted',0);
690 690
 						  $this->db->where('status',0);
691
-			      $account_info=(array)$this->db->get_where('accounts',array("number"=>$csv_data['accountid']))->first_row();
692
-			      if($account_info){
693
-			          $account_balance=$this->db_model->get_available_bal($account_info);
694
-			          $setup = $this->common_model->add_calculate_currency($csv_data['setup'], '', '', false, false);
695
-			          if($account_balance >= $setup){
696
-			            $field_name=$account_info['type']==1 ? 'parent_id':'accountid';
697
-			            $currency_name=$this->common->get_field_name('currency',"currency",array('id'=>$account_info['currency_id']));
698
-				    $csv_data['monthlycost'] = $this->common_model->add_calculate_currency($csv_data['monthlycost'], '', '', false, false);
699
-				    $csv_data['cost'] = $this->common_model->add_calculate_currency($csv_data['cost'], '', '', false, false);
700
-				    $csv_data['connectcost'] = $this->common_model->add_calculate_currency($csv_data['connectcost'], '', '', false, false);
701
-				    $csv_data['setup']=$setup;
702
-				    $csv_data[$field_name]=$account_info['id'];
703
-				    $csv_data['status']=$this->common->get_import_status($csv_data['status']);
704
-				    $available_bal = $this->db_model->update_balance($csv_data["setup"],$account_info['id'], "debit");
705
-				    $account_info['did_number'] = $csv_data['number'];
706
-				    $account_info['did_country_id'] = $csv_data['country_id'];
707
-				    $account_info['did_setup'] = $this->common_model->calculate_currency($csv_data['setup'],'',$currency_name,true,true);
708
-				    $account_info['did_monthlycost'] = $this->common_model->calculate_currency($csv_data['monthlycost'],'',$currency_name,true,true);
709
-				    $account_info['did_maxchannels'] = "0";
710
-				    $csv_data['country_id']=$this->common->get_field_name('id','countrycode',array("country"=>$csv_data['country_id']));
711
-				    if($account_info['type']==1){
712
-				     $reseller_array=$csv_data;
713
-				     $reseller_array['note']=$csv_data['number'];
714
-				     $reseller_array['reseller_id']=$account_info['id'];
715
-				     $reseller_array['parent_id']=$account_info['reseller_id'];
716
-				     $reseller_array['assign_date']=gmdate("Y-m-d H:i:s");
717
-				     unset($reseller_array['number'],$csv_data['accountid'],$reseller_array['accountid'],$reseller_array['country_id'],$reseller_array['init_inc']);
718
-				     $csv_data['accountid']=0;
719
-				     $final_reseller_array[$i]=$reseller_array;
720
-				    }else{
721
-				      $csv_data['parent_id']=0;
722
-				    }
723
-				    $csv_data['assign_date']=gmdate("Y-m-d H:i:s");
724
-				    $new_final_arr[$i] = $csv_data;
725
-				    $this->common->mail_to_users('email_add_did', $account_info);
726
-			          }else{
727
-				    $invalid_array[$i] = $csv_data;
728
-				    $invalid_array[$i]['error'] = 'Account have not sufficient amount to purchase this DID.';
729
-			          }
730
-			      }else{
691
+				  $account_info=(array)$this->db->get_where('accounts',array("number"=>$csv_data['accountid']))->first_row();
692
+				  if($account_info){
693
+					  $account_balance=$this->db_model->get_available_bal($account_info);
694
+					  $setup = $this->common_model->add_calculate_currency($csv_data['setup'], '', '', false, false);
695
+					  if($account_balance >= $setup){
696
+						$field_name=$account_info['type']==1 ? 'parent_id':'accountid';
697
+						$currency_name=$this->common->get_field_name('currency',"currency",array('id'=>$account_info['currency_id']));
698
+					$csv_data['monthlycost'] = $this->common_model->add_calculate_currency($csv_data['monthlycost'], '', '', false, false);
699
+					$csv_data['cost'] = $this->common_model->add_calculate_currency($csv_data['cost'], '', '', false, false);
700
+					$csv_data['connectcost'] = $this->common_model->add_calculate_currency($csv_data['connectcost'], '', '', false, false);
701
+					$csv_data['setup']=$setup;
702
+					$csv_data[$field_name]=$account_info['id'];
703
+					$csv_data['status']=$this->common->get_import_status($csv_data['status']);
704
+					$available_bal = $this->db_model->update_balance($csv_data["setup"],$account_info['id'], "debit");
705
+					$account_info['did_number'] = $csv_data['number'];
706
+					$account_info['did_country_id'] = $csv_data['country_id'];
707
+					$account_info['did_setup'] = $this->common_model->calculate_currency($csv_data['setup'],'',$currency_name,true,true);
708
+					$account_info['did_monthlycost'] = $this->common_model->calculate_currency($csv_data['monthlycost'],'',$currency_name,true,true);
709
+					$account_info['did_maxchannels'] = "0";
710
+					$csv_data['country_id']=$this->common->get_field_name('id','countrycode',array("country"=>$csv_data['country_id']));
711
+					if($account_info['type']==1){
712
+					 $reseller_array=$csv_data;
713
+					 $reseller_array['note']=$csv_data['number'];
714
+					 $reseller_array['reseller_id']=$account_info['id'];
715
+					 $reseller_array['parent_id']=$account_info['reseller_id'];
716
+					 $reseller_array['assign_date']=gmdate("Y-m-d H:i:s");
717
+					 unset($reseller_array['number'],$csv_data['accountid'],$reseller_array['accountid'],$reseller_array['country_id'],$reseller_array['init_inc']);
718
+					 $csv_data['accountid']=0;
719
+					 $final_reseller_array[$i]=$reseller_array;
720
+					}else{
721
+					  $csv_data['parent_id']=0;
722
+					}
723
+					$csv_data['assign_date']=gmdate("Y-m-d H:i:s");
724
+					$new_final_arr[$i] = $csv_data;
725
+					$this->common->mail_to_users('email_add_did', $account_info);
726
+					  }else{
727
+					$invalid_array[$i] = $csv_data;
728
+					$invalid_array[$i]['error'] = 'Account have not sufficient amount to purchase this DID.';
729
+					  }
730
+				  }else{
731 731
 				$invalid_array[$i] = $csv_data;
732 732
 				$invalid_array[$i]['error'] = 'Account not found or assign to invalid account';
733
-			      }
734
-                            }else{
735
-			      $csv_data['setup'] = $this->common_model->add_calculate_currency($csv_data['setup'], '', '', false, false);
736
-			      $csv_data['monthlycost'] = $this->common_model->add_calculate_currency($csv_data['monthlycost'], '', '', false, false);
737
-			      $csv_data['cost'] = $this->common_model->add_calculate_currency($csv_data['cost'], '', '', false, false);
738
-			      $csv_data['connectcost'] = $this->common_model->add_calculate_currency($csv_data['connectcost'], '', '', false, false);
739
-			      $csv_data['accountid']=0;
740
-			      $csv_data['country_id']=$this->common->get_field_name('id','countrycode',array("country"=>$csv_data['country_id']));
741
-			      $new_final_arr[$i] = $csv_data;
742
-                            }
743
-                        }
744
-                    } else {
745
-                        $invalid_array[$i] = $csv_data;
746
-                        $invalid_array[$i]['error'] = 'Duplicate DID found from import file.';
747
-                    }
748
-                }
749
-                $number_arr[] = $csv_data['number'];
750
-            }
751
-            $i++;
752
-        }
753
-        if (!empty($new_final_arr)) {
754
-           $result = $this->did_model->bulk_insert_dids($new_final_arr);
755
-        }
756
-        if(!empty($final_reseller_array)){
757
-            $this->db->insert_batch('reseller_pricing', $final_reseller_array);
758
-        }
733
+				  }
734
+							}else{
735
+				  $csv_data['setup'] = $this->common_model->add_calculate_currency($csv_data['setup'], '', '', false, false);
736
+				  $csv_data['monthlycost'] = $this->common_model->add_calculate_currency($csv_data['monthlycost'], '', '', false, false);
737
+				  $csv_data['cost'] = $this->common_model->add_calculate_currency($csv_data['cost'], '', '', false, false);
738
+				  $csv_data['connectcost'] = $this->common_model->add_calculate_currency($csv_data['connectcost'], '', '', false, false);
739
+				  $csv_data['accountid']=0;
740
+				  $csv_data['country_id']=$this->common->get_field_name('id','countrycode',array("country"=>$csv_data['country_id']));
741
+				  $new_final_arr[$i] = $csv_data;
742
+							}
743
+						}
744
+					} else {
745
+						$invalid_array[$i] = $csv_data;
746
+						$invalid_array[$i]['error'] = 'Duplicate DID found from import file.';
747
+					}
748
+				}
749
+				$number_arr[] = $csv_data['number'];
750
+			}
751
+			$i++;
752
+		}
753
+		if (!empty($new_final_arr)) {
754
+		   $result = $this->did_model->bulk_insert_dids($new_final_arr);
755
+		}
756
+		if(!empty($final_reseller_array)){
757
+			$this->db->insert_batch('reseller_pricing', $final_reseller_array);
758
+		}
759 759
 	unlink($full_path.$did_file_name);
760
-        $count = count($invalid_array);
761
-        if ($count > 0) {
762
-            $session_id = "-1";
763
-            $fp = fopen($full_path . $session_id . '.csv', 'w');
764
-            foreach ($new_final_arr_key as $key => $value) {
765
-                $custom_array[0][$key] = ucfirst($key);
766
-            }
767
-            $custom_array[0]['error'] = "Error";
768
-            $invalid_array = array_merge($custom_array, $invalid_array);
769
-            foreach ($invalid_array as $err_data) {
770
-                fputcsv($fp, $err_data);
771
-            }
772
-            fclose($fp);
773
-            $this->session->set_userdata('import_did_csv_error', $session_id . ".csv");
774
-            $data["error"] = $invalid_array;
775
-            $data['provider_id'] = $provider_id;
776
-            $data['import_record_count'] = count($new_final_arr)+count($reseller_array);
777
-            $data['failure_count'] = count($invalid_array) - 1;
778
-            $data['page_title'] = 'DID Import Error';
779
-            $this->load->view('view_import_error', $data);
780
-        } else {
781
-            $this->session->set_flashdata('astpp_errormsg', 'Total ' . count($new_final_arr) . ' DIDs Imported Successfully!');
782
-            redirect(base_url() . "did/did_list/");
783
-        }
784
-    }
785
-
786
-    function data_validate($csvdata) {
787
-        $str = null;
788
-        $alpha_regex = "/^[a-z ,.'-]+$/i";
789
-        $alpha_numeric_regex = "/^[a-z0-9 ,.'-]+$/i";
790
-        $email_regex = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/";
791
-        $str.= $csvdata['number'] != '' ? null : 'Number,';
792
-        $str = rtrim($str, ',');
793
-        if (!$str) {
794
-            $str.= is_numeric($csvdata['number']) ? null : 'Number,';
795
-            $str.=!empty($csvdata['connectcost']) && is_numeric($csvdata['connectcost']) ? null : ( empty($csvdata['connectcost']) ? null : 'Connect Cost,');
796
-            $str.=!empty($csvdata['includedseconds']) && is_numeric($csvdata['includedseconds']) ? null : ( empty($csvdata['includedseconds']) ? null : 'Included Seconds,');
797
-            if ($str) {
798
-                $str = rtrim($str, ',');
799
-                $error_field = explode(',', $str);
800
-                $count = count($error_field);
801
-                $str.= $count > 1 ? ' are not valid' : ' is not Valid';
802
-                return $str;
803
-            } else {
804
-                return false;
805
-            }
806
-        } else {
807
-            $str = rtrim($str, ',');
808
-            $error_field = explode(',', $str);
809
-            $count = count($error_field);
810
-            $str.= $count > 1 ? ' are required' : ' is Required';
811
-            return $str;
812
-        }
813
-    }
814
-
815
-    function did_error_download() {
816
-        $this->load->helper('download');
817
-        $error_data = $this->session->userdata('import_did_csv_error');
818
-        $full_path = $this->config->item('rates-file-path');
819
-        $data = file_get_contents($full_path . $error_data);
820
-        force_download("error_did_rates.csv", $data);
821
-    }
822
-
823
-    function did_export_data_xls() {
760
+		$count = count($invalid_array);
761
+		if ($count > 0) {
762
+			$session_id = "-1";
763
+			$fp = fopen($full_path . $session_id . '.csv', 'w');
764
+			foreach ($new_final_arr_key as $key => $value) {
765
+				$custom_array[0][$key] = ucfirst($key);
766
+			}
767
+			$custom_array[0]['error'] = "Error";
768
+			$invalid_array = array_merge($custom_array, $invalid_array);
769
+			foreach ($invalid_array as $err_data) {
770
+				fputcsv($fp, $err_data);
771
+			}
772
+			fclose($fp);
773
+			$this->session->set_userdata('import_did_csv_error', $session_id . ".csv");
774
+			$data["error"] = $invalid_array;
775
+			$data['provider_id'] = $provider_id;
776
+			$data['import_record_count'] = count($new_final_arr)+count($reseller_array);
777
+			$data['failure_count'] = count($invalid_array) - 1;
778
+			$data['page_title'] = 'DID Import Error';
779
+			$this->load->view('view_import_error', $data);
780
+		} else {
781
+			$this->session->set_flashdata('astpp_errormsg', 'Total ' . count($new_final_arr) . ' DIDs Imported Successfully!');
782
+			redirect(base_url() . "did/did_list/");
783
+		}
784
+	}
785
+
786
+	function data_validate($csvdata) {
787
+		$str = null;
788
+		$alpha_regex = "/^[a-z ,.'-]+$/i";
789
+		$alpha_numeric_regex = "/^[a-z0-9 ,.'-]+$/i";
790
+		$email_regex = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/";
791
+		$str.= $csvdata['number'] != '' ? null : 'Number,';
792
+		$str = rtrim($str, ',');
793
+		if (!$str) {
794
+			$str.= is_numeric($csvdata['number']) ? null : 'Number,';
795
+			$str.=!empty($csvdata['connectcost']) && is_numeric($csvdata['connectcost']) ? null : ( empty($csvdata['connectcost']) ? null : 'Connect Cost,');
796
+			$str.=!empty($csvdata['includedseconds']) && is_numeric($csvdata['includedseconds']) ? null : ( empty($csvdata['includedseconds']) ? null : 'Included Seconds,');
797
+			if ($str) {
798
+				$str = rtrim($str, ',');
799
+				$error_field = explode(',', $str);
800
+				$count = count($error_field);
801
+				$str.= $count > 1 ? ' are not valid' : ' is not Valid';
802
+				return $str;
803
+			} else {
804
+				return false;
805
+			}
806
+		} else {
807
+			$str = rtrim($str, ',');
808
+			$error_field = explode(',', $str);
809
+			$count = count($error_field);
810
+			$str.= $count > 1 ? ' are required' : ' is Required';
811
+			return $str;
812
+		}
813
+	}
814
+
815
+	function did_error_download() {
816
+		$this->load->helper('download');
817
+		$error_data = $this->session->userdata('import_did_csv_error');
818
+		$full_path = $this->config->item('rates-file-path');
819
+		$data = file_get_contents($full_path . $error_data);
820
+		force_download("error_did_rates.csv", $data);
821
+	}
822
+
823
+	function did_export_data_xls() {
824 824
 	$account_info = $accountinfo = $this->session->userdata('accountinfo');
825 825
 	$currency_id=$account_info['currency_id'];
826 826
 	$currency=$this->common->get_field_name('currency', 'currency', $currency_id);
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 	$outbound_array[] = array("DID", "Country", "Account","Per Minute Cost($currency)","Initial Increment","Increment","Setup Fee($currency)","Monthly Fee($currency)","Call Type","Destination","Status","Modified Date","Is Purchased");
830 830
 	if ($query->num_rows() > 0) {
831 831
 	  foreach ($query->result_array() as $row) {
832
-	    $outbound_array[] = array(
832
+		$outbound_array[] = array(
833 833
 		$row['number'],
834 834
 		$this->common->get_field_name("country", "countrycode", $row['country_id']),
835 835
 		$this->common->get_field_name("number", "accounts", $row['accountid']),
@@ -843,12 +843,12 @@  discard block
 block discarded – undo
843 843
 		$this->common->get_status('export','',$row['status']),
844 844
 		$row['last_modified_date'],
845 845
 		$this->common->check_did_avl_export($row['number'])
846
-	    );
846
+		);
847 847
 	  }
848 848
 	}
849
-        $this->load->helper('csv');
850
-        array_to_csv($outbound_array, 'DIDs_' . date("Y-m-d") . '.csv');
851
-    }
849
+		$this->load->helper('csv');
850
+		array_to_csv($outbound_array, 'DIDs_' . date("Y-m-d") . '.csv');
851
+	}
852 852
 
853 853
 }
854 854
 ?>
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/did/libraries/did_form.php 1 patch
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -23,188 +23,188 @@  discard block
 block discarded – undo
23 23
 ###############################################################################
24 24
 
25 25
 if (!defined('BASEPATH'))
26
-    exit('No direct script access allowed');
26
+	exit('No direct script access allowed');
27 27
 
28 28
 class did_form {
29 29
 
30
-    function __construct() {
31
-        $this->CI = & get_instance();
32
-    }
30
+	function __construct() {
31
+		$this->CI = & get_instance();
32
+	}
33 33
 
34
-    function get_dids_form_fields($id=false,$parent_id='0',$account_id='0') {
35
-    if ($id != 0){
36
-      if($parent_id > 0){
34
+	function get_dids_form_fields($id=false,$parent_id='0',$account_id='0') {
35
+	if ($id != 0){
36
+	  if($parent_id > 0){
37 37
 	  $account_dropdown =  array('Reseller',  array('name' => 'parent_id', 'disabled' => 'disabled','class' => 'accountid', 'id' => 'accountid'), 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0","type"=>"1", "deleted" => "0","status" => "0"));                
38
-      }else{
38
+	  }else{
39 39
 	  if($account_id > 0){
40
-	    $account_dropdown =  array('Account ',  array('name' => 'accountid', 'disabled' => 'disabled','class' => 'accountid', 'id' => 'accountid'), 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0","type"=>"0,3", "deleted" => "0","status" => "0"));
40
+		$account_dropdown =  array('Account ',  array('name' => 'accountid', 'disabled' => 'disabled','class' => 'accountid', 'id' => 'accountid'), 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0","type"=>"0,3", "deleted" => "0","status" => "0"));
41 41
 	  }
42 42
 	  else{
43
-	    $account_dropdown = array('Account', 'accountid', 'SELECT', '',array("name"=>"accountid","rules"=>"did_account_checking"), 'tOOL TIP', 'Please Enter account number', 'id',  'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0", "type" => "0,3","deleted" => "0","status" => "0" ));
43
+		$account_dropdown = array('Account', 'accountid', 'SELECT', '',array("name"=>"accountid","rules"=>"did_account_checking"), 'tOOL TIP', 'Please Enter account number', 'id',  'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0", "type" => "0,3","deleted" => "0","status" => "0" ));
44
+	  }
44 45
 	  }
45
-      }
46 46
    } else{
47 47
 	$account_dropdown = array('Account', 'accountid', 'SELECT','' , array("name"=>"accountid","rules"=>"did_account_checking"), 'tOOL TIP', 'Please Enter account number', 'id',  'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0", "type" => "0,3", "deleted" => "0","status" => "0" ));
48 48
    }
49 49
 
50 50
 	$val= $id > 0 ? 'dids.number.'.$id : 'dids.number';
51
-        $form['forms'] = array(base_url() . '/did/did_save/', array('id' => 'did_form', 'method' => 'POST', 'name' => 'did_form'));
52
-        $form['DID Information'] = array(
53
-            array('', 'HIDDEN', array('name' => 'id'), '', '', '', ''),
54
-            array('DID', 'INPUT', array('name' => 'number', 'size' => '20', 'class' => "text field medium"), 'trim|required|is_numeric|xss_clean|integer', 'tOOL TIP', 'Please Enter account number'),
55
-              array('Country',array('name'=>'country_id','class'=>'country_id'), 'SELECT', '',array("name"=>"country_id","rules"=>"required"), 'tOOL TIP', 'Please Enter account number', 'id', 'country', 'countrycode', 'build_dropdown', '', ''),
56
-            array('City', 'INPUT', array('name' => 'city', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter Password'),
57
-            array('Province', 'INPUT', array('name' => 'province', 'size' => '15', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter Password'),
51
+		$form['forms'] = array(base_url() . '/did/did_save/', array('id' => 'did_form', 'method' => 'POST', 'name' => 'did_form'));
52
+		$form['DID Information'] = array(
53
+			array('', 'HIDDEN', array('name' => 'id'), '', '', '', ''),
54
+			array('DID', 'INPUT', array('name' => 'number', 'size' => '20', 'class' => "text field medium"), 'trim|required|is_numeric|xss_clean|integer', 'tOOL TIP', 'Please Enter account number'),
55
+			  array('Country',array('name'=>'country_id','class'=>'country_id'), 'SELECT', '',array("name"=>"country_id","rules"=>"required"), 'tOOL TIP', 'Please Enter account number', 'id', 'country', 'countrycode', 'build_dropdown', '', ''),
56
+			array('City', 'INPUT', array('name' => 'city', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter Password'),
57
+			array('Province', 'INPUT', array('name' => 'province', 'size' => '15', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter Password'),
58 58
 			array('Provider', 'provider_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("type" => "3", "deleted" => "0","status" => "0")),
59
-        );
59
+		);
60 60
 
61
-        $form['Billing Information'] = array(
61
+		$form['Billing Information'] = array(
62 62
 			$account_dropdown,    
63 63
 			array('Connection Cost', 'INPUT', array('name' => 'connectcost', 'size' => '15',  'class' => "text field medium"), 'trim|is_numeric|xss_clean', 'tOOL TIP', 'Please Enter Password'),       
64 64
 			array('Included Seconds', 'INPUT', array('name' => 'includedseconds', 'size' => '50',  'class' => "text field medium"), 'trim|is_numeric|xss_clean', 'tOOL TIP', 'Please Enter Password'),
65 65
 			array('Per Minute Cost', 'INPUT', array('name' => 'cost', 'size' => '15',  'class' => "text field medium"), 'trim|is_numeric|xss_clean', 'tOOL TIP', 'Please Enter Password'),
66 66
 			array('Initial Increment', 'INPUT', array('name' => 'init_inc', 'size' => '20',  'class' => "text field medium"), 'trim|is_numeric|xss_clean', 'tOOL TIP', 'Please Enter Initial Increment'),
67 67
 			array('Increment', 'INPUT', array('name' => 'inc', 'size' => '20',  'class' => "text field medium"), 'trim|is_numeric|xss_clean', 'tOOL TIP', 'Please Enter Increment'),
68
-            array('Setup Fee', 'INPUT', array('name' => 'setup',  'size' => '15', 'class' => 'text field medium'), 'trim|is_numeric|xss_clean', 'tOOL TIP', ''),
69
-            array('Monthly<br>Fee', 'INPUT', array('name' => 'monthlycost', 'size' => '15',  'class' => "text field medium"), 'trim|is_numeric|xss_clean', 'tOOL TIP', 'Please Enter Password'),
70
-        );
68
+			array('Setup Fee', 'INPUT', array('name' => 'setup',  'size' => '15', 'class' => 'text field medium'), 'trim|is_numeric|xss_clean', 'tOOL TIP', ''),
69
+			array('Monthly<br>Fee', 'INPUT', array('name' => 'monthlycost', 'size' => '15',  'class' => "text field medium"), 'trim|is_numeric|xss_clean', 'tOOL TIP', 'Please Enter Password'),
70
+		);
71 71
 
72
-        $form['DID Setting'] = array(
73
-            array('Call Type', 'call_type', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_call_type', ''),
74
-            array('Destination', 'INPUT', array('name' => 'extensions', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter Password'),
75
-            array('Concurrent Calls', 'INPUT', array('name' => 'maxchannels', 'size' => '20',  'class' => "text field medium"), 'trim|is_numeric|xss_clean', 'tOOL TIP', 'Please Enter account number'),
76
-            array('Status', 'status', 'SELECT', '', '', 'tOOL TIP', 'Please Select Status', '', '', '', 'set_status'),
72
+		$form['DID Setting'] = array(
73
+			array('Call Type', 'call_type', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_call_type', ''),
74
+			array('Destination', 'INPUT', array('name' => 'extensions', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter Password'),
75
+			array('Concurrent Calls', 'INPUT', array('name' => 'maxchannels', 'size' => '20',  'class' => "text field medium"), 'trim|is_numeric|xss_clean', 'tOOL TIP', 'Please Enter account number'),
76
+			array('Status', 'status', 'SELECT', '', '', 'tOOL TIP', 'Please Select Status', '', '', '', 'set_status'),
77 77
 
78
-        );
78
+		);
79 79
 
80
-        $form['button_save'] = array('name' => 'action', 'content' => 'Save', 'value' => 'save', 'id' => 'submit', 'type' => 'button', 'class' => 'btn btn-line-parrot');
81
-        $form['button_cancel'] = array('name' => 'action', 'content' => 'Close', 'value' => 'cancel', 'type' => 'button', 'class' => 'btn btn-line-sky margin-x-10', 'onclick' => 'return redirect_page(\'NULL\')');
82
-        return $form;
83
-    }
80
+		$form['button_save'] = array('name' => 'action', 'content' => 'Save', 'value' => 'save', 'id' => 'submit', 'type' => 'button', 'class' => 'btn btn-line-parrot');
81
+		$form['button_cancel'] = array('name' => 'action', 'content' => 'Close', 'value' => 'cancel', 'type' => 'button', 'class' => 'btn btn-line-sky margin-x-10', 'onclick' => 'return redirect_page(\'NULL\')');
82
+		return $form;
83
+	}
84 84
 
85
-    /***************************************************************************/
85
+	/***************************************************************************/
86 86
 
87
-    function get_search_did_form() {
87
+	function get_search_did_form() {
88 88
 
89 89
     
90
-        $form['forms'] = array("", array('id' => "did_search"));
91
-        $form['Search'] = array(
92
-            array('DID', 'INPUT', array('name' => 'number[number]', '', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'number[number-string]', '', '', '', 'search_string_type', ''),
93
-            array('Country', 'country_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'country', 'countrycode', 'build_dropdown', '', ''),
94
-            array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0","type"=>"0", "deleted" => "0")),
95
-            array('Initial Increment', 'INPUT', array('name' => 'init_inc[init_inc]', '', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '1', 'init_inc[init_inc-integer]', '', '', '', 'search_int_type', ''),
96
-            array('Call Type', 'call_type', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_call_type_search', '',''),
97
-            array('Destination', 'INPUT', array('name' => 'extensions[extensions]', '', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'extensions[extensions-string]', '', '', '', 'search_string_type', ''),
90
+		$form['forms'] = array("", array('id' => "did_search"));
91
+		$form['Search'] = array(
92
+			array('DID', 'INPUT', array('name' => 'number[number]', '', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'number[number-string]', '', '', '', 'search_string_type', ''),
93
+			array('Country', 'country_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'country', 'countrycode', 'build_dropdown', '', ''),
94
+			array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0","type"=>"0", "deleted" => "0")),
95
+			array('Initial Increment', 'INPUT', array('name' => 'init_inc[init_inc]', '', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '1', 'init_inc[init_inc-integer]', '', '', '', 'search_int_type', ''),
96
+			array('Call Type', 'call_type', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_call_type_search', '',''),
97
+			array('Destination', 'INPUT', array('name' => 'extensions[extensions]', '', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'extensions[extensions-string]', '', '', '', 'search_string_type', ''),
98 98
 		array('Status', 'status', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_search_status', '', ''),
99 99
             
100 100
 		array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),array('', 'HIDDEN', 'advance_search', '1', '', '', '')
101
-          );
101
+		  );
102 102
 
103
-        $form['button_search'] = array('name' => 'action', 'id' => "did_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right');
104
-        $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10');
103
+		$form['button_search'] = array('name' => 'action', 'id' => "did_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right');
104
+		$form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10');
105 105
 
106
-        return $form;
107
-    }
106
+		return $form;
107
+	}
108 108
 
109
-        function get_search_did_form_for_reseller() {
109
+		function get_search_did_form_for_reseller() {
110 110
 
111 111
     
112
-        $form['forms'] = array("", array('id' => "did_search"));
113
-        $form['Search'] = array(
114
-            array('DID', 'INPUT', array('name' => 'note[note]', '', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'note[note-string]', '', '', '', 'search_string_type', ''),
112
+		$form['forms'] = array("", array('id' => "did_search"));
113
+		$form['Search'] = array(
114
+			array('DID', 'INPUT', array('name' => 'note[note]', '', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'note[note-string]', '', '', '', 'search_string_type', ''),
115 115
  	  array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0","type"=>"0", "deleted" => "0")),
116 116
 	   array('Call Type', 'call_type', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_call_type_search', '',''),
117 117
 	  array('Destination', 'INPUT', array('name' => 'extensions[extensions]', '', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'extensions[extensions-string]', '', '', '', 'search_string_type', ''),
118 118
 	  array('Status', 'status', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_search_status', '', ''),
119 119
 	  array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),array('', 'HIDDEN', 'advance_search', '1', '', '', '')
120
-          );
120
+		  );
121 121
 
122
-        $form['button_search'] = array('name' => 'action', 'id' => "did_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right');
123
-        $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10');
122
+		$form['button_search'] = array('name' => 'action', 'id' => "did_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right');
123
+		$form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10');
124 124
 
125
-        return $form;
126
-    }
125
+		return $form;
126
+	}
127 127
 
128 128
 
129
-    /*
129
+	/*
130 130
     ASTPP  3.0  grid size is change.
131 131
     */
132
-    function build_did_list_for_admin() {
132
+	function build_did_list_for_admin() {
133 133
 		  $account_info = $accountinfo = $this->CI->session->userdata('accountinfo');
134
-    $currency_id=$account_info['currency_id'];
135
-     $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id);
134
+	$currency_id=$account_info['currency_id'];
135
+	 $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id);
136 136
 		
137 137
 		
138
-       // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
139
-        $grid_field_arr = json_encode(array(array("<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", "30", "", "", "", "","","false","center"),
138
+	   // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
139
+		$grid_field_arr = json_encode(array(array("<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", "30", "", "", "", "","","false","center"),
140 140
 
141 141
 /**
142 142
 ASTPP  3.0 
143 143
 For DID edit on DID number
144 144
 **/
145
-            array(gettext("DID"), "80", "number", "", "", "","EDITABLE","true","center"),
146
-            array(gettext("Country"), "60", "country_id", "country", "countrycode", "get_field_name","","true","center"),
147
-            array(gettext("Account"), "95", "accountid", "first_name,last_name,number", "accounts", "get_field_name_coma_new"),
148
-            array("Per Minute <br>Cost($currency)", "85", "cost", "cost", "cost", "convert_to_currency","","true","right"),
149
-            array(gettext("Initial <br>Increment"), "80", "init_inc", "", "", "","","true","center"),
150
-            array(gettext("Increment"), "90", "inc", "", "", "","","true","center"),
151
-            array("Setup <br>Fee($currency)", "70", "setup", "setup", "setup", "convert_to_currency","","true","right"),
152
-            array("Monthly<br>Fee($currency)", "90", "monthlycost", "monthlycost", "monthlycost", "convert_to_currency","","true","right"),
153
-            array(gettext("Call Type"), "90", "call_type", "call_type", "call_type", "get_call_type","","true","center"),
154
-            array(gettext("Destination"), "80", "extensions", "", "", "","","true","center"),       
155
-            array(gettext("Status"), "90", "status", "status", "dids", "get_status","","true","center"),
156
-            array(gettext("Modified <br/>Date"), "90", "last_modified_date", "last_modified_date", "last_modified_date", "convert_GMT_to","","true","center"),
157
-            array(gettext("Is Purchased?"), "110", "number", "number", "number", "check_did_avl","","true","center"),
158
-    	    array("Action", "100", "", "", "", array("EDIT" => array("url" => "did/did_edit/", "mode" => "popup","layout"=>"medium"),
159
-                    "DELETE" => array("url" => "did/did_remove/", "mode" => "single")))
160
-            ));
161
-        return $grid_field_arr;
162
-    }
163
-     /*****************************************************************************************/
164
-     /*
145
+			array(gettext("DID"), "80", "number", "", "", "","EDITABLE","true","center"),
146
+			array(gettext("Country"), "60", "country_id", "country", "countrycode", "get_field_name","","true","center"),
147
+			array(gettext("Account"), "95", "accountid", "first_name,last_name,number", "accounts", "get_field_name_coma_new"),
148
+			array("Per Minute <br>Cost($currency)", "85", "cost", "cost", "cost", "convert_to_currency","","true","right"),
149
+			array(gettext("Initial <br>Increment"), "80", "init_inc", "", "", "","","true","center"),
150
+			array(gettext("Increment"), "90", "inc", "", "", "","","true","center"),
151
+			array("Setup <br>Fee($currency)", "70", "setup", "setup", "setup", "convert_to_currency","","true","right"),
152
+			array("Monthly<br>Fee($currency)", "90", "monthlycost", "monthlycost", "monthlycost", "convert_to_currency","","true","right"),
153
+			array(gettext("Call Type"), "90", "call_type", "call_type", "call_type", "get_call_type","","true","center"),
154
+			array(gettext("Destination"), "80", "extensions", "", "", "","","true","center"),       
155
+			array(gettext("Status"), "90", "status", "status", "dids", "get_status","","true","center"),
156
+			array(gettext("Modified <br/>Date"), "90", "last_modified_date", "last_modified_date", "last_modified_date", "convert_GMT_to","","true","center"),
157
+			array(gettext("Is Purchased?"), "110", "number", "number", "number", "check_did_avl","","true","center"),
158
+			array("Action", "100", "", "", "", array("EDIT" => array("url" => "did/did_edit/", "mode" => "popup","layout"=>"medium"),
159
+					"DELETE" => array("url" => "did/did_remove/", "mode" => "single")))
160
+			));
161
+		return $grid_field_arr;
162
+	}
163
+	 /*****************************************************************************************/
164
+	 /*
165 165
      ASTPP  3.0 
166 166
      change in grid size
167 167
      */
168
-        function build_did_list_for_reseller_login() {
168
+		function build_did_list_for_reseller_login() {
169 169
 	 $account_info = $accountinfo = $this->CI->session->userdata('accountinfo');
170
-    	$currency_id=$account_info['currency_id'];
171
-     	$currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id);	
172
-        // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
173
-        $grid_field_arr = json_encode(array(
174
-            array("DID", "90", "number", "", "", "","EDITABLE","","true","center"),
175
-            array("Account", "100", "accountid", "first_name,last_name,number", "accounts", "get_field_name_coma_new","","true","center"),
176
-            array("Per Minute<br>Cost($currency)", "80", "cost", "cost", "cost", "convert_to_currency","","true","right"),
177
-            array("Initial <br>Increment", "100", "init_inc", "", "", "","","true","center"),
178
-            array("Increment", "95", "inc", "", "", "","","true","center"),
179
-            array("Setup <br> Fee($currency)", "90", "setup", "setup", "setup", "convert_to_currency","","true","right"),
180
-            array("Monthly<br> fee($currency)", "90", "monthlycost", "monthlycost", "monthlycost", "convert_to_currency","","true","right"),
181
-            array("Call Type", "80", "call_type", "call_type", "call_type", "get_call_type","","true","center"),
182
-            array("Destination", "95", "extensions", "", "", "","","true","center"),
183
-            array("Status", "90", "status", "status", "reseller_pricing", "get_status","","true","center"),
184
-            array("Modified Date", "130", "last_modified_date", "last_modified_date", "last_modified_date", "convert_GMT_to","","true","center"),
185
-            array("Is purchased?", "100", "number", "number", "number", "check_did_avl_reseller","","true","center"),
186
-	    array("Action", "90", "", "", "", array("EDIT" => array("url" => "did/did_reseller_edit/edit/", "mode" => "popup"),
187
-                    "DELETE" => array("url" => "did/did_reseller_edit/delete/", "mode" => "single")))
188
-                ));
189
-        return $grid_field_arr;
190
-    }
191
-    /************************************************************************/
192
-    function build_grid_buttons() {
193
-        $buttons_json = json_encode(array(
194
-            array(gettext("Create"),"btn btn-line-warning btn","fa fa-plus-circle fa-lg", "button_action", "/did/did_add/", "popup","medium"),
195
-            array(gettext("Delete"), "btn btn-line-danger","fa fa-times-circle fa-lg", "button_action", "/did/did_delete_multiple/"),
196
-            array(gettext("Import"), "btn btn-line-blue","fa fa-upload fa-lg", "button_action", "/did/did_import/", '',"small"),            
170
+		$currency_id=$account_info['currency_id'];
171
+	 	$currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id);	
172
+		// array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
173
+		$grid_field_arr = json_encode(array(
174
+			array("DID", "90", "number", "", "", "","EDITABLE","","true","center"),
175
+			array("Account", "100", "accountid", "first_name,last_name,number", "accounts", "get_field_name_coma_new","","true","center"),
176
+			array("Per Minute<br>Cost($currency)", "80", "cost", "cost", "cost", "convert_to_currency","","true","right"),
177
+			array("Initial <br>Increment", "100", "init_inc", "", "", "","","true","center"),
178
+			array("Increment", "95", "inc", "", "", "","","true","center"),
179
+			array("Setup <br> Fee($currency)", "90", "setup", "setup", "setup", "convert_to_currency","","true","right"),
180
+			array("Monthly<br> fee($currency)", "90", "monthlycost", "monthlycost", "monthlycost", "convert_to_currency","","true","right"),
181
+			array("Call Type", "80", "call_type", "call_type", "call_type", "get_call_type","","true","center"),
182
+			array("Destination", "95", "extensions", "", "", "","","true","center"),
183
+			array("Status", "90", "status", "status", "reseller_pricing", "get_status","","true","center"),
184
+			array("Modified Date", "130", "last_modified_date", "last_modified_date", "last_modified_date", "convert_GMT_to","","true","center"),
185
+			array("Is purchased?", "100", "number", "number", "number", "check_did_avl_reseller","","true","center"),
186
+		array("Action", "90", "", "", "", array("EDIT" => array("url" => "did/did_reseller_edit/edit/", "mode" => "popup"),
187
+					"DELETE" => array("url" => "did/did_reseller_edit/delete/", "mode" => "single")))
188
+				));
189
+		return $grid_field_arr;
190
+	}
191
+	/************************************************************************/
192
+	function build_grid_buttons() {
193
+		$buttons_json = json_encode(array(
194
+			array(gettext("Create"),"btn btn-line-warning btn","fa fa-plus-circle fa-lg", "button_action", "/did/did_add/", "popup","medium"),
195
+			array(gettext("Delete"), "btn btn-line-danger","fa fa-times-circle fa-lg", "button_action", "/did/did_delete_multiple/"),
196
+			array(gettext("Import"), "btn btn-line-blue","fa fa-upload fa-lg", "button_action", "/did/did_import/", '',"small"),            
197 197
 			array(gettext("Export"),"btn btn-xing" ,"fa fa-download fa-lg", "button_action", "/did/did_export_data_xls", 'single')
198
-            ));
199
-        return $buttons_json;
200
-    }
198
+			));
199
+		return $buttons_json;
200
+	}
201 201
 
202
-    function build_did_list_for_customer($accountid, $accounttype) {
202
+	function build_did_list_for_customer($accountid, $accounttype) {
203 203
 	$account_info = $accountinfo = $this->CI->session->userdata('accountinfo');
204 204
 	$currency_id=$account_info['currency_id'];
205 205
 	$currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id);
206
-        // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
207
-        $grid_field_arr = json_encode(array(
206
+		// array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
207
+		$grid_field_arr = json_encode(array(
208 208
 	array("DID", "110", "number", "", "", "","","true","center"),
209 209
 	array("Country", "110", "country_id", "country", "countrycode", "get_field_name","","true","center"),
210 210
 	array("Per Minute Cost($currency)", "150", "cost", "cost", "cost", "convert_to_currency","","true","right"),
@@ -213,25 +213,25 @@  discard block
 block discarded – undo
213 213
 	array("Setup Fee($currency)", "140", "setup", "setup", "setup", "convert_to_currency","","true","right"),
214 214
 	array("Monthly Fee($currency)", "140", "monthlycost", "monthlycost", "monthlycost", "convert_to_currency","","true","right"),
215 215
 	array("Action", "110", "", "", "", array("DELETE" => array("url" => "accounts/".$accounttype."_dids_action/delete/$accountid/$accounttype/", "mode" => "single")))
216
-	    ));
217
-        return $grid_field_arr;
218
-    }
219
-
220
-    function build_did_list_for_reseller($accountid, $accounttype) {
221
-        // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
222
-        $grid_field_arr = json_encode(array(array("DID Number", "120", "number", "", "", ""),
223
-            array("Increment", "120", "inc", "", "", ""),
224
-            array("Is purchased?", "120", "number", "number", "number", "check_did_avl_reseller"),
225
-            array("Per Minute Cost", "120", "cost", "cost", "cost", "convert_to_currency"),
226
-            array("Included<br> Seconds", "100", "includedseconds", "", "", ""),
227
-            array("Setup <br> Fee", "109", "setup", "setup", "setup", "convert_to_currency"),
228
-            array("Monthly<br> Fee", "140", "monthlycost", "monthlycost", "monthlycost", "convert_to_currency"),
229
-            array("Connection Cost", "149", "connectcost", "connectcost", "connectcost", "convert_to_currency"),
230
-            array("Disconnection <br> Fee", "140", "disconnectionfee", "disconnectionfee", "disconnectionfee", "convert_to_currency"),
231
-            array("Action", "100", "", "", "", array("DELETE" => array("url" => "/accounts/reseller_did_action/delete/$accountid/$accounttype/", "mode" => "single")))
232
-                ));
233
-        return $grid_field_arr;
234
-    }
216
+		));
217
+		return $grid_field_arr;
218
+	}
219
+
220
+	function build_did_list_for_reseller($accountid, $accounttype) {
221
+		// array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
222
+		$grid_field_arr = json_encode(array(array("DID Number", "120", "number", "", "", ""),
223
+			array("Increment", "120", "inc", "", "", ""),
224
+			array("Is purchased?", "120", "number", "number", "number", "check_did_avl_reseller"),
225
+			array("Per Minute Cost", "120", "cost", "cost", "cost", "convert_to_currency"),
226
+			array("Included<br> Seconds", "100", "includedseconds", "", "", ""),
227
+			array("Setup <br> Fee", "109", "setup", "setup", "setup", "convert_to_currency"),
228
+			array("Monthly<br> Fee", "140", "monthlycost", "monthlycost", "monthlycost", "convert_to_currency"),
229
+			array("Connection Cost", "149", "connectcost", "connectcost", "connectcost", "convert_to_currency"),
230
+			array("Disconnection <br> Fee", "140", "disconnectionfee", "disconnectionfee", "disconnectionfee", "convert_to_currency"),
231
+			array("Action", "100", "", "", "", array("DELETE" => array("url" => "/accounts/reseller_did_action/delete/$accountid/$accounttype/", "mode" => "single")))
232
+				));
233
+		return $grid_field_arr;
234
+	}
235 235
     
236 236
     
237 237
 }
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/did/views/view_did_import.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
             	<div class="w-box">
18 18
             	 <span  style="margin-left:10px; text-align: center;background-color: none;color:#1c8400;">
19 19
                     <? if(isset($error) && !empty($error)) {
20
-                        echo $error;
21
-                    }?>
20
+						echo $error;
21
+					}?>
22 22
                  </span>
23 23
                    <h3 class="padding-t-10 padding-l-16">File must be in the following format:<br />
24 24
                 number,account,connectcost,includedseconds,monthlyfee,cost,extensions,status,provider,country,province,city,increment
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                                <label class="col-md-3">Trunk List:</label>
35 35
                                <div>
36 36
                                <? $trunklist = form_dropdown('trunk_id', $this->db_model->build_dropdown("id,name", "trunks", "", ""), '');
37
-                            echo $trunklist; ?></div>
37
+							echo $trunklist; ?></div>
38 38
                            </div>
39 39
                            <div class="col-md-12 no-padding"s>
40 40
                             <input type="hidden" name="mode" value="Import DIDs" />
Please login to merge, or discard this patch.
astpp/application/modules/did/views/view_did_manage_reseller_add.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@
 block discarded – undo
47 47
                         <label class="col-md-3 no-padding">Call Type</label>
48 48
                   		  <select name="call_type" class="col-md-5 form-control selectpicker" data-live-search='true'>
49 49
                   		  <?php $calltype=$this->common->set_call_type();
50
-                  		     foreach($calltype as $key=>$value){
51
-                  		       $selected=$reseller_didinfo['call_type']==$key ? "selected='selected'" : '';
52
-                  		       echo "<option value='$key'$selected>$value</option>";
53
-                  		     }
54
-                  		     ?>
50
+				  			 foreach($calltype as $key=>$value){
51
+				  			   $selected=$reseller_didinfo['call_type']==$key ? "selected='selected'" : '';
52
+				  			   echo "<option value='$key'$selected>$value</option>";
53
+				  			 }
54
+				  			 ?>
55 55
                 		    </select>
56 56
         		    </li>
57 57
                  <li class="col-md-12">
Please login to merge, or discard this patch.