| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | // ############################################################################## | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | // ASTPP - Open Source VoIP Billing Solution | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | // test66666666666 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | // Copyright (C) 2016 iNextrix Technologies Pvt. Ltd. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | // Samir Doshi <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | // ASTPP Version 3.0 and above | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | // License https://www.gnu.org/licenses/agpl-3.0.html | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | // This program is free software: you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | // it under the terms of the GNU Affero General Public License as | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | // published by the Free Software Foundation, either version 3 of the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | // License, or (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | // This program is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | // GNU Affero General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | // You should have received a copy of the GNU Affero General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | // along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | // ############################################################################## | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | class Rates extends MX_Controller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	function Rates() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 		parent::__construct(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 		$this->load->helper('template_inheritance'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 		$this->load->library('session'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 		$this->load->library('rates_form'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 		$this->load->library('astpp/form'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 		$this->load->model('rates_model'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 		$this->load->library('csvreader'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 		ini_set("memory_limit", "2048M"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		ini_set("max_execution_time", "259200"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 		ini_set("upload_max_filesize", "200M"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		if ($this->session->userdata('user_login') == FALSE) redirect(base_url() . '/astpp/login'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 43 |  | View Code Duplication | 	function termination_rates_list() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		$data['username'] = $this->session->userdata('user_name'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 		$data['page_title'] = 'Termination Rates'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 		$data['search_flag'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 		$data['batch_update_flag'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		/********* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		ASTPP  3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		Batch Delete | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		*********/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 		$data['delete_batch_flag'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		/***************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		$this->session->set_userdata('advance_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		$data['grid_fields'] = $this->rates_form->build_termination_rate_for_admin(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		$data["grid_buttons"] = $this->rates_form->build_grid_buttons(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		$data['form_search'] = $this->form->build_serach_form($this->rates_form->get_termination_rate_search_form()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		$data['form_batch_update'] = $this->form->build_batchupdate_form($this->rates_form->termination_rate_batch_update_form()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 		$this->load->view('view_termination_rates_list', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	 * -------Here we write code for controller accounts functions account_list------ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	 * Listing of Accounts table data through php function json_encode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	function termination_rates_list_json() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 		$json_data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 		$count_all = $this->rates_model->get_termination_rates_list(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		$json_data = $paging_data["json_paging"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 		$query = $this->rates_model->get_termination_rates_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 		$grid_fields = json_decode($this->rates_form->build_termination_rate_for_admin()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 		$json_data['rows'] = $this->form->build_grid($query, $grid_fields); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 		echo json_encode($json_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 79 |  | View Code Duplication | 	function termination_rates_list_delete($flag = '') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 		$json_data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 		$this->session->set_userdata('advance_batch_data_delete', 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 		$count_all = $this->rates_model->get_termination_rates_list(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 		echo $count_all; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	/****************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 	function termination_rate_import() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 		$data['page_title'] = 'Import Termination Rates'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 		$this->session->set_userdata('import_termination_rate_csv', ""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 		$this->session->set_userdata('import_termination_rate_csv_error', ""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 		$this->load->view('view_import_termination_rate', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 	function termination_rate_preview_file() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		$invalid_flag = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 		$check_header = $this->input->post('check_header', true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 		$data['page_title'] = 'Import Termination Rates'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 		$new_final_arr_key = $this->config->item('Termination-rates-field'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		if (empty($_FILES) || !isset($_FILES)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 			redirect(base_url() . "rates/termination_rates_list/"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 		if (isset($_FILES['termination_rate_import']['name']) && $_FILES['termination_rate_import']['name'] != "" && isset($_POST['trunk_id']) && $_POST['trunk_id'] != '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 			list($txt, $ext) = explode(".", $_FILES['termination_rate_import']['name']); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 			if ($ext == "csv" && $_FILES['termination_rate_import']['size'] > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 				$error = $_FILES['termination_rate_import']['error']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 				if ($error == 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 					$uploadedFile = $_FILES["termination_rate_import"]["tmp_name"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 					$csv_data = $this->csvreader->parse_file($uploadedFile, $new_final_arr_key, $check_header); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 					if (!empty($csv_data)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 						$full_path = $this->config->item('rates-file-path'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 						$actual_file_name = "ASTPP-TERMINATION-RATES-" . date("Y-m-d-H:i:s") . "." . $ext; | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 121 |  | View Code Duplication | 						if (move_uploaded_file($uploadedFile, $full_path . $actual_file_name)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 							$data['csv_tmp_data'] = $csv_data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 							$data['trunkid'] = $_POST['trunk_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 							$data['check_header'] = $check_header; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 							$data['page_title'] = 'Termination Rates Preview'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 							$this->session->set_userdata('import_termination_rate_csv', $actual_file_name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 						else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 							$data['error'] = "File Uploading Fail Please Try Again"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 				else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 					$data['error'] == "File Uploading Fail Please Try Again"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 			else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 				$data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 			$invalid_flag = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 150 |  | View Code Duplication | 		if ($invalid_flag) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 			$str = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 			if (!isset($_POST['trunk_id']) || empty($_POST['trunk_id'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 				$str.= '<br/>Please Create Trunk.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 			if (empty($_FILES['termination_rate_import']['name'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 				$str.= '<br/>Please Select  File.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 			$data['error'] = $str; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 		$this->load->view('view_import_termination_rate', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 	function termination_rate_rates_import($trunkID, $check_header = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 		$new_final_arr = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 		$invalid_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 		$new_final_arr_key = $this->config->item('Termination-rates-field'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 		$screen_path = $this->config->item('screen_path'); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 175 |  | View Code Duplication | 		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 			$account_data = $this->session->userdata("accountinfo"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 		$full_path = $this->config->item('rates-file-path'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 		$terminationrate_file_name = $this->session->userdata('import_termination_rate_csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 		$csv_tmp_data = $this->csvreader->parse_file($full_path . $terminationrate_file_name, $new_final_arr_key, $check_header); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 		$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 		foreach($csv_tmp_data as $key => $csv_data) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 			if (isset($csv_data['pattern']) && $csv_data['pattern'] != '' && $i != 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 				$str = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 				$csv_data['prepend'] = isset($csv_data['prepend']) ? $csv_data['prepend'] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 				$csv_data['comment'] = isset($csv_data['comment']) ? $csv_data['comment'] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 				$csv_data['connectcost'] = isset($csv_data['connectcost']) ? $csv_data['connectcost'] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 				$csv_data['includedseconds'] = isset($csv_data['includedseconds']) ? $csv_data['includedseconds'] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 				$csv_data['cost'] = !empty($csv_data['cost']) && is_numeric($csv_data['cost']) ? $csv_data['cost'] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 				$csv_data['inc'] = isset($csv_data['inc']) ? $csv_data['inc'] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 				$csv_data['precedence'] = isset($csv_data['precedence']) ? $csv_data['precedence'] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 				$csv_data['strip'] = isset($csv_data['strip']) ? $csv_data['strip'] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 				$csv_data['last_modified_date'] = date("Y-m-d H:i:s"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 				$str = $this->data_validate($csv_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 				if ($str != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 					$invalid_array[$i] = $csv_data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 					$invalid_array[$i]['error'] = $str; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 				else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 					$csv_data['trunk_id'] = $trunkID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 					$csv_data['pattern'] = "^" . $csv_data['pattern'] . ".*"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 					$new_final_arr[$i] = $csv_data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 			$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 		if (!empty($new_final_arr)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 			$result = $this->rates_model->bulk_insert_termination_rate($new_final_arr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 		unlink($full_path . $terminationrate_file_name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 		$count = count($invalid_array); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 222 |  | View Code Duplication | 		if ($count > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 			$session_id = "-1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 			$fp = fopen($full_path . $session_id . '.csv', 'w'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 			foreach($new_final_arr_key as $key => $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 				$custom_array[0][$key] = ucfirst($key); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 			$custom_array[0]['error'] = "Error"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 			$invalid_array = array_merge($custom_array, $invalid_array); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 			foreach($invalid_array as $err_data) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 				fputcsv($fp, $err_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 			fclose($fp); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 			$this->session->set_userdata('import_termination_rate_csv_error', $session_id . ".csv"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 			$data["error"] = $invalid_array; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 			$data['trunkid'] = $trunkID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 			$data['impoted_count'] = count($new_final_arr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 			$data['failure_count'] = count($invalid_array) - 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 			$data['page_title'] = 'Termination Rates Import Error'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 			$this->load->view('view_import_error', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 			$this->session->set_flashdata('astpp_errormsg', 'Total ' . count($new_final_arr) . ' Termination rates imported successfully!'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 			redirect(base_url() . "rates/termination_rates_list/"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 254 |  | View Code Duplication | 	function termination_rate_error_download() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 		$this->load->helper('download'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 		$error_data = $this->session->userdata('import_termination_rate_csv_error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 		$full_path = $this->config->item('rates-file-path'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 		$data = file_get_contents($full_path . $error_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 		force_download("Termination_rate_error.csv", $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 263 |  | View Code Duplication | 	function origination_rate_import() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 		$data['page_title'] = 'Import Origination Rates'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 		$this->session->set_userdata('import_origination_rate_csv', ""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 		$error_data = $this->session->userdata('import_origination_rate_csv_error'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 		$full_path = $this->config->item('rates-file-path'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 		if (file_exists($full_path . $error_data) && $error_data != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 			unlink($full_path . $error_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 			$this->session->set_userdata('import_origination_rate_csv_error', ""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 		$this->load->view('view_import_origination_rate', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 	function origination_rate_preview_file() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 		$invalid_flag = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 		$data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 		$data['page_title'] = 'Import Origination Rates'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 		$check_header = $this->input->post('check_header', true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 		if (empty($_FILES) || !isset($_FILES)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 			redirect(base_url() . "rates/origination_rate_list/"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 		$get_extension = strpos($_FILES['origination_rate_import']['name'], '.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 		$new_final_arr_key = $this->config->item('Origination-rates-field'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 		if (!$get_extension) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 			$data['error'] = "Please Upload File Atleast"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 		if (isset($_FILES['origination_rate_import']['name']) && $_FILES['origination_rate_import']['name'] != "" && isset($_POST['pricelist_id']) && $_POST['pricelist_id'] != '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 			list($txt, $ext) = explode(".", $_FILES['origination_rate_import']['name']); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 			if ($ext == "csv" && $_FILES['origination_rate_import']['size'] > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 				$error = $_FILES['origination_rate_import']['error']; | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 302 |  | View Code Duplication | 				if ($error == 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 					$uploadedFile = $_FILES["origination_rate_import"]["tmp_name"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 					$csv_data = $this->csvreader->parse_file($uploadedFile, $new_final_arr_key, $check_header); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 					if (!empty($csv_data)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 						$full_path = $this->config->item('rates-file-path'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 						$actual_file_name = "ASTPP-ORIGIN-RATES-" . date("Y-m-d H:i:s") . "." . $ext; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 						if (move_uploaded_file($uploadedFile, $full_path . $actual_file_name)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 							$flag = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 							$data['trunkid'] = isset($_POST['trunk_id']) && $_POST['trunk_id'] > 0 ? $_POST['trunk_id'] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 							$data['csv_tmp_data'] = $csv_data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 							$data['pricelistid'] = $_POST['pricelist_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 							$data['page_title'] = "Origination Rates Preview"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 							$data['check_header'] = $check_header; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 							$this->session->set_userdata('import_origination_rate_csv', $actual_file_name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 						else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 							$data['error'] = "File Uploading Fail Please Try Again"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 				else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 					$data['error'] == "File Uploading Fail Please Try Again"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 			else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 				$data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 			$invalid_flag = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 341 |  | View Code Duplication | 		if ($invalid_flag) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 			$str = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 			if (!isset($_POST['pricelist_id']) || empty($_POST['pricelist_id'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 				$str.= '<br/>Please Create Rate Group.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 			if (empty($_FILES['origination_rate_import']['name'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 				$str.= '<br/>Please Select File.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 			$data['error'] = $str; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | 		$this->load->view('view_import_origination_rate', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 	function origination_rate_import_file($pricelistID, $trunkid, $check_header = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 		$new_final_arr = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 		$invalid_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 		$new_final_arr_key = $this->config->item('Origination-rates-field'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 		$screen_path = $this->config->item('screen_path'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 		$reseller_id = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 			$reseller_id = $this->session->userdata["accountinfo"]['id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 		$full_path = $this->config->item('rates-file-path'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 		$originationrate_file_name = $this->session->userdata('import_origination_rate_csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 		$csv_tmp_data = $this->csvreader->parse_file($full_path . $originationrate_file_name, $new_final_arr_key, $check_header); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 		// echo "<pre>";print_r($csv_tmp_data);exit; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 		$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 		foreach($csv_tmp_data as $key => $csv_data) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 			if (isset($csv_data['pattern']) && $csv_data['pattern'] != '' && $i != 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 				$str = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 				$csv_data['comment'] = isset($csv_data['comment']) ? $csv_data['comment'] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 				$csv_data['connectcost'] = isset($csv_data['connectcost']) ? $csv_data['connectcost'] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 				$csv_data['includedseconds'] = isset($csv_data['includedseconds']) ? $csv_data['includedseconds'] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 				$csv_data['cost'] = !empty($csv_data['cost']) && is_numeric($csv_data['cost']) ? $csv_data['cost'] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 				$csv_data['inc'] = isset($csv_data['inc']) ? $csv_data['inc'] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 				$csv_data['precedence'] = isset($csv_data['precedence']) ? $csv_data['precedence'] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 				$csv_data['last_modified_date'] = date("Y-m-d H:i:s"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 				$str = $this->data_validate($csv_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 				if ($str != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 					$invalid_array[$i] = $csv_data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 					$invalid_array[$i]['error'] = $str; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 				else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 					$csv_data['pricelist_id'] = $pricelistID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 					$csv_data['trunk_id'] = $trunkid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 					$csv_data['pattern'] = "^" . $csv_data['pattern'] . ".*"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 					$csv_data['reseller_id'] = $reseller_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 					$csv_data['creation_date'] = gmdate('Y-m-d H:i:s'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 					$new_final_arr[$i] = $csv_data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 			$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 		if (!empty($new_final_arr)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 			$result = $this->rates_model->bulk_insert_origination_rate($new_final_arr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 		unlink($full_path . $originationrate_file_name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 		$count = count($invalid_array); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 418 |  | View Code Duplication | 		if ($count > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 			$session_id = "-1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 			$fp = fopen($full_path . $session_id . '.csv', 'w'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 			foreach($new_final_arr_key as $key => $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | 				$custom_array[0][$key] = ucfirst($key); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 			$custom_array[0]['error'] = "Error"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 			$invalid_array = array_merge($custom_array, $invalid_array); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 			foreach($invalid_array as $err_data) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 				fputcsv($fp, $err_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 			fclose($fp); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 			$this->session->set_userdata('import_origination_rate_csv_error', $session_id . ".csv"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 			$data["error"] = $invalid_array; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 			$data['pricelistid'] = $pricelistID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 			$data['impoted_count'] = count($new_final_arr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 			$data['failure_count'] = count($invalid_array) - 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 			$data['page_title'] = 'Origination Rates Import Error'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 			$this->load->view('view_import_error', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 			$this->session->set_flashdata('astpp_errormsg', 'Total ' . count($new_final_arr) . ' Origination rates imported successfully!'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 			redirect(base_url() . "rates/origination_rates_list/"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 	function data_validate($csvdata) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 		$str = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 		$alpha_regex = "/^[a-z ,.'-]+$/i"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 		$alpha_numeric_regex = "/^[a-z0-9 ,.'-]+$/i"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 		$email_regex = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  | 		$str.= $csvdata['pattern'] != '' ? null : 'Code,'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 		$str = rtrim($str, ','); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 		if (!$str) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 			$str.= is_numeric($csvdata['pattern']) ? null : 'Code,'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 			$str.= !empty($csvdata['connectcost']) && is_numeric($csvdata['connectcost']) ? null : (empty($csvdata['connectcost']) ? null : 'Connect Cost,'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 			$str.= !empty($csvdata['includedseconds']) && is_numeric($csvdata['includedseconds']) ? null : (empty($csvdata['includedseconds']) ? null : 'Included Seconds,'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 			$str.= !empty($csvdata['inc']) && is_numeric($csvdata['inc']) ? null : (empty($csvdata['inc']) ? null : 'Increment,'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 			$str.= !empty($csvdata['precedence']) && is_numeric($csvdata['precedence']) ? null : (empty($csvdata['precedence']) ? null : 'Precedence,'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 			$str.= (isset($csvdata['strip']) && !empty($csvdata['strip'])) ? (is_numeric($csvdata['strip']) ? null : 'Strip,') : null; | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 466 |  | View Code Duplication | 			if ($str) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 				$str = rtrim($str, ','); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | 				$error_field = explode(',', $str); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 				$count = count($error_field); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 				$str.= $count > 1 ? ' are not valid' : ' is not Valid'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 				return $str; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 			else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 			$str = rtrim($str, ','); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  | 			$error_field = explode(',', $str); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 			$count = count($error_field); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 			$str.= $count > 1 ? ' are required' : ' is Required'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 			return $str; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 488 |  |  |  | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 489 |  | View Code Duplication | 	function origination_rate_error_download() | 
            
                                                                        
                            
            
                                    
            
            
                | 490 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 491 |  |  | 		$this->load->helper('download'); | 
            
                                                                        
                            
            
                                    
            
            
                | 492 |  |  | 		$error_data = $this->session->userdata('import_origination_rate_csv_error'); | 
            
                                                                        
                            
            
                                    
            
            
                | 493 |  |  | 		$full_path = $this->config->item('rates-file-path'); | 
            
                                                                        
                            
            
                                    
            
            
                | 494 |  |  | 		$data = file_get_contents($full_path . $error_data); | 
            
                                                                        
                            
            
                                    
            
            
                | 495 |  |  | 		force_download("Origination_rate_error.csv", $data); | 
            
                                                                        
                            
            
                                    
            
            
                | 496 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 498 |  | View Code Duplication | 	function origination_rate_add($type = "") | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 		$data['username'] = $this->session->userdata('user_name'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 		$data['flag'] = 'create'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 		$data['page_title'] = 'Create Origination Rate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 		$data['form'] = $this->form->build_form($this->rates_form->get_origination_rate_form_fields() , ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 		$this->load->view('view_origination_rate_add_edit', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 	function origination_rate_edit($edit_id = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 		$data['page_title'] = 'Edit Origination Rate'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  | 		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 			$account_data = $this->session->userdata("accountinfo"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 			$reseller = $account_data['id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 			$where = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 				'id' => $edit_id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 				"reseller_id" => $reseller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  | 			$where = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 				'id' => $edit_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 		$account = $this->db_model->getSelect("*", "routes", $where); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 		if ($account->num_rows > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 			foreach($account->result_array() as $key => $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 				$edit_data = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 			$edit_data['connectcost'] = $this->common_model->to_calculate_currency($edit_data['connectcost'], '', '', true, false); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 			$edit_data['cost'] = $this->common_model->to_calculate_currency($edit_data['cost'], '', '', true, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 			$edit_data['pattern'] = filter_var($edit_data['pattern'], FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 			$data['form'] = $this->form->build_form($this->rates_form->get_origination_rate_form_fields() , $edit_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 			$this->load->view('view_origination_rate_add_edit', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 			redirect(base_url() . 'rates/origination_rate_list/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 546 |  | View Code Duplication | 	function origination_rate_save() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 		$add_array = $this->input->post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 		$data['form'] = $this->form->build_form($this->rates_form->get_origination_rate_form_fields() , $add_array); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 		if ($add_array['id'] != '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 			$data['page_title'] = 'Edit Origination Rate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 			if ($this->form_validation->run() == FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 				$data['validation_errors'] = validation_errors(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 				echo $data['validation_errors']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 				exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 			else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 				$add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 				$add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 				$this->rates_model->edit_origination_rate($add_array, $add_array['id']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 				echo json_encode(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 					"SUCCESS" => "Origination rate updated successfully!" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 				)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 				exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 			$data['page_title'] = 'Add Origination Rate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 			if ($this->form_validation->run() == FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 				$data['validation_errors'] = validation_errors(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 				echo $data['validation_errors']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 				exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  | 			else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 				$add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 				$add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 				$this->rates_model->add_origination_rate($add_array); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 				echo json_encode(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 					"SUCCESS" => "Origination rate added successfully!" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 				)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 				exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 592 |  | View Code Duplication | 	function origination_rates_list_search() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 		$ajax_search = $this->input->post('ajax_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 		if ($this->input->post('advance_search', TRUE) == 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 			$this->session->set_userdata('advance_search', $this->input->post('advance_search')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 			$action = $this->input->post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  | 			unset($action['action']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 			unset($action['advance_search']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 			$this->session->set_userdata('origination_rate_list_search', $action); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 		if (@$ajax_search != 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 			redirect(base_url() . 'rates/origination_rates_list/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  | 	function origination_rates_list_clearsearchfilter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  | 		$this->session->set_userdata('advance_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  | 		$this->session->set_userdata('account_search', ""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  | 	function termination_rate_delete($id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 		$this->rates_model->remove_termination_rate($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  | 		$this->session->set_flashdata('astpp_notification', 'Termination removed successfully!'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  | 		redirect(base_url() . '/rates/termination_rates_list/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  | 	function origination_rate_delete($id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  | 		$this->rates_model->remove_origination_rate($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  | 		$this->session->set_flashdata('astpp_notification', 'Origination rate removed successfully!'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 		redirect(base_url() . 'rates/origination_rates_list/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 630 |  | View Code Duplication | 	function origination_rates_list() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  | 		$data['username'] = $this->session->userdata('user_name'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  | 		$data['page_title'] = 'Origination Rates'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  | 		$data['search_flag'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 		$data['batch_update_flag'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 		/********* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 		ASTPP  3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 		Batch Delete | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  | 		*********/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  | 		$data['delete_batch_flag'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  | 		/***************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  | 		$this->session->set_userdata('advance_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  | 		$data['grid_fields'] = $this->rates_form->build_origination_rate_list_for_admin(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  | 		$data["grid_buttons"] = $this->rates_form->build_grid_buttons_origination_rate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  | 		$data['form_search'] = $this->form->build_serach_form($this->rates_form->get_origination_rate_search_form()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  | 		$data['form_batch_update'] = $this->form->build_batchupdate_form($this->rates_form->origination_rate_batch_update_form()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  | 		$this->load->view('view_origination_rate_list', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  | 	/********* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  | 	ASTPP  3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  | 	Batch Delete | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  | 	*********/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  | 	function origination_rates_list_json() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  | 		$json_data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  | 		$count_all = $this->rates_model->get_origination_rate_list(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  | 		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  | 		$json_data = $paging_data["json_paging"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  | 		// echo "<pre>"; print_r($json_data); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  | 		$query = $this->rates_model->get_origination_rate_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  | 		$grid_fields = json_decode($this->rates_form->build_origination_rate_list_for_admin()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  | 		$json_data['rows'] = $this->form->build_grid($query, $grid_fields); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  | 		echo json_encode($json_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 669 |  | View Code Duplication | 	function origination_rates_list_delete($flag = '') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  | 		$json_data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  | 		$this->session->set_userdata('advance_batch_data_delete', 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  | 		$count_all = $this->rates_model->get_origination_rate_list(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  | 		echo $count_all; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  | 	/*******************/ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 678 |  | View Code Duplication | 	function termination_rate_add($type = "") | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  | 		$data['username'] = $this->session->userdata('user_name'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  | 		$data['flag'] = 'create'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  | 		$data['page_title'] = 'Create Termination Rate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  | 		$data['form'] = $this->form->build_form($this->rates_form->get_termination_rate_form_fields() , ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  | 		$this->load->view('view_termination_rate_add_edit', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  | 	function termination_rate_edit($edit_id = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  | 		$data['page_title'] = 'Edit Termination Rate'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  | 		$where = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  | 			'id' => $edit_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  | 		$account = $this->db_model->getSelect("*", "outbound_routes", $where); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 		foreach($account->result_array() as $key => $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  | 			$edit_data = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  | 		$edit_data['connectcost'] = $this->common_model->to_calculate_currency($edit_data['connectcost'], '', '', false, false); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  | 		$edit_data['cost'] = $this->common_model->to_calculate_currency($edit_data['cost'], '', '', false, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  | 		$edit_data['pattern'] = filter_var($edit_data['pattern'], FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 		$data['form'] = $this->form->build_form($this->rates_form->get_termination_rate_form_fields() , $edit_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  | 		$this->load->view('view_termination_rate_add_edit', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 706 |  | View Code Duplication | 	function termination_rate_save() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  | 		$add_array = $this->input->post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  | 		$data['form'] = $this->form->build_form($this->rates_form->get_termination_rate_form_fields() , $add_array); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  | 		if ($add_array['id'] != '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  | 			$data['page_title'] = 'Edit Termination Rate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  | 			if ($this->form_validation->run() == FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  | 				$data['validation_errors'] = validation_errors(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  | 				echo $data['validation_errors']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  | 				exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  | 			else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  | 				$add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  | 				$add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  | 				$this->rates_model->edit_termination_rate($add_array, $add_array['id']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  | 				echo json_encode(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  | 					"SUCCESS" => "Termination updated successfully!" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  | 				)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  | 				exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  | 			$data['page_title'] = 'Add Termination Rate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  | 			if ($this->form_validation->run() == FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  | 				$data['validation_errors'] = validation_errors(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  | 				echo $data['validation_errors']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  | 				exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  | 			else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  | 				$add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  | 				$add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  | 				$this->rates_model->add_termination_rate($add_array); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  | 				echo json_encode(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  | 					"SUCCESS" => "Termination added successfully!" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  | 				)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  | 				exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  | 		$this->load->view('view_termination_rate_add_edit', $data); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 754 |  | View Code Duplication | 	function termination_rates_list_search() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  | 		$ajax_search = $this->input->post('ajax_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  | 		if ($this->input->post('advance_search', TRUE) == 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  | 			$this->session->set_userdata('advance_search', $this->input->post('advance_search')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  | 			$action = $this->input->post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  | 			unset($action['action']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  | 			unset($action['advance_search']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  | 			$this->session->set_userdata('termination_rates_list_search', $action); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  | 		if (@$ajax_search != 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  | 			redirect(base_url() . 'rates/termination_rates_list/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  | 	function termination_rates_list_clearsearchfilter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  | 		$this->session->set_userdata('advance_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  | 		$this->session->set_userdata('account_search', ""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 778 |  | View Code Duplication | 	function customer_block_pattern_list($accountid, $accounttype) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  | 		$json_data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  | 		$where = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  | 			'accountid' => $accountid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  | 		$instant_search = $this->session->userdata('left_panel_search_' . $accounttype . '_pattern'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  | 		$like_str = !empty($instant_search) ? "(blocked_patterns like '%$instant_search%'  OR  destination like '%$instant_search%' )" : null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  | 		if (!empty($like_str)) $this->db->where($like_str); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  | 		$count_all = $this->db_model->countQuery("*", "block_patterns", $where); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  | 		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  | 		$json_data = $paging_data["json_paging"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  | 		if (!empty($like_str)) $this->db->where($like_str); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  | 		$pattern_data = $this->db_model->getSelect("*", "block_patterns", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  | 		$grid_fields = json_decode($this->rates_form->build_pattern_list_for_customer($accountid, $accounttype)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  | 		$json_data['rows'] = $this->form->build_grid($pattern_data, $grid_fields); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  | 		echo json_encode($json_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  | 	function termination_rate_delete_multiple() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  | 		$ids = $this->input->post("selected_ids", true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  | 		$where = "id IN ($ids)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  | 		$this->db->where($where); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  | 		echo $this->db->delete("outbound_routes"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  | 	function origination_rate_delete_multiple() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  | 		$ids = $this->input->post("selected_ids", true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  | 		$where = "id IN ($ids)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  | 		$this->db->where($where); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  | 		echo $this->db->delete("routes"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  | 	function user_origination_rate_list_json() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  | 		$json_data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  | 		$account_data = $this->session->userdata("accountinfo"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  | 		$markup = $this->common->get_field_name('markup', 'pricelists', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  | 			'id' => $account_data["pricelist_id"] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  | 		$markup = ($markup > 0) ? $markup : 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  | 		$count_all = $this->rates_model->get_origination_rate_list_for_user(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  | 		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  | 		$json_data = $paging_data["json_paging"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  | 		$query = $this->rates_model->get_origination_rate_list_for_user(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  | 		$grid_fields = json_decode($this->rates_form->build_origination_rate_list_for_user()); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 826 |  | View Code Duplication | 		foreach($query->result_array() as $key => $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  | 			$json_data['rows'][] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  | 				'cell' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  | 					$this->common->get_only_numeric_val("", "", $value["pattern"]) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  | 					$value['comment'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  | 					$value['inc'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  | 					$this->common_model->calculate_currency(($value['cost'] + ($value['cost'] * $markup) / 100) , '', '', '', true) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  | 					$this->common_model->calculate_currency($value['connectcost'], '', '', '', true) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  | 					$value['includedseconds'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  | 				) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  | 		//        $json_data['rows'] = $this->form->build_grid($query, $grid_fields); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  | 		echo json_encode($json_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 845 |  | View Code Duplication | 	function user_origination_rate_list_search() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  | 		$ajax_search = $this->input->post('ajax_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  | 		if ($this->input->post('advance_search', TRUE) == 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  | 			$this->session->set_userdata('advance_search', $this->input->post('advance_search')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  | 			$action = $this->input->post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  | 			unset($action['action']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  | 			unset($action['advance_search']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  | 			$this->session->set_userdata('origination_rate_list_search', $action); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  | 		if (@$ajax_search != 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  | 			redirect(base_url() . 'user/user_rates_list/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  | 	function user_origination_rate_list_clearsearchfilter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  | 		$this->session->set_userdata('advance_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  | 		$this->session->set_userdata('account_search', ""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 869 |  | View Code Duplication | 	function customer_rates_download_sample_file($file_name) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  | 		$this->load->helper('download'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  | 		$full_path = base_url() . "assets/Rates_File/" . $file_name . ".csv"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  | 		$arrContextOptions = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  | 			"ssl" => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  | 				"verify_peer" => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  | 				"verify_peer_name" => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  | 			) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  | 		$file = file_get_contents($full_path, false, stream_context_create($arrContextOptions)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  | 		force_download("samplefile.csv", $file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  | 	function termination_rate_batch_update() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  | 		$batch_update_arr = $this->input->post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  | 		$batch_update_arr["cost"]["cost"] = isset($batch_update_arr["cost"]["cost"]) ? $this->common_model->add_calculate_currency($batch_update_arr["cost"]["cost"], '', '', true, false) : "0.0000"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  | 		$batch_update_arr["connectcost"]["connectcost"] = isset($batch_update_arr["connectcost"]["connectcost"]) ? $this->common_model->add_calculate_currency($batch_update_arr["connectcost"]["connectcost"], '', '', true, false) : "0.0000"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  | 		//        $batch_update_arr = array("inc"=> array("inc"=>"1","operator"=>"3"),"cost"=> array("cost"=>"1","operator"=>"4")); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  | 		$result = $this->rates_model->termination_rate_batch_update($batch_update_arr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  | 		echo json_encode(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  | 			"SUCCESS" => "Termination rates batch updated successfully!" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  | 		exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  | 	function origination_rate_batch_update() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  | 		$batch_update_arr = $this->input->post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  | 		$batch_update_arr["cost"]["cost"] = isset($batch_update_arr["cost"]["cost"]) ? $this->common_model->add_calculate_currency($batch_update_arr["cost"]["cost"], '', '', true, false) : "0.0000"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  | 		//        $batch_update_arr = array("inc"=> array("inc"=>"1","operator"=>"3"),"cost"=> array("cost"=>"1","operator"=>"4")); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  | 		$result = $this->rates_model->origination_rate_batch_update($batch_update_arr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  | 		echo json_encode(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  | 			"SUCCESS" => "Origination rates batch updated successfully!" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  | 		exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  | 	function termination_rate_export_cdr_xls() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  | 		$account_info = $accountinfo = $this->session->userdata('accountinfo'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  | 		$currency_id = $account_info['currency_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  | 		$currency = $this->common->get_field_name('currency', 'currency', $currency_id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  | 		$query = $this->rates_model->get_termination_rate(true, '', '', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  | 		$outbound_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  | 		ob_clean(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  | 		$outbound_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  | 			"Code", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  | 			"Destination", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  | 			"Connect Cost($currency)", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  | 			"Included Seconds", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  | 			"Per Minute Cost($currency)", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  | 			"Initial Increment", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  | 			"Increment", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  | 			"Priority", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  | 			"Strip", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  | 			"Prepend", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  | 			"Trunk", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  | 			"Status", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  | 			"Created Date" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  | 		if ($query->num_rows() > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  | 			foreach($query->result_array() as $row) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  | 				// echo"<pre>";print_r($row);exit; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 |  |  | 				$outbound_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  | 					$row['pattern'] = $this->common->get_only_numeric_val("", "", $row["pattern"]) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  | 					$row['comment'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  | 					$this->common_model->calculate_currency($row['connectcost'], '', '', TRUE, false) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  | 					$row['includedseconds'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  | 					$this->common_model->calculate_currency($row['cost'], '', '', TRUE, false) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  | 					/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  | 					 ASTPP  3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  | 					 For Add Initial Increment field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  | 					 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  | 					 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  | 					$row['init_inc'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  | 					/****************************************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  | 					$row['inc'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  | 					$row['precedence'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  | 					$row['strip'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  | 					$row['prepend'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  | 					// $row['trunk_id'], | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  | 					$this->common->get_field_name('name', 'trunks', $row["trunk_id"]) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  | 					$this->common->get_status('export', '', $row['status']) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  | 					$row['creation_date'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 966 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 967 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 968 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 969 |  |  | 		$this->load->helper('csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 970 |  |  | 		array_to_csv($outbound_array, 'Termination_Rates_' . date("Y-m-d") . '.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 971 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 972 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 973 |  |  | 	function termination_rate_export_cdr_pdf() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 974 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 975 |  |  | 		$query = $this->rates_model->get_termination_rate(true, '', '', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 976 |  |  | 		$outbound_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 977 |  |  | 		$this->load->library('fpdf'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 978 |  |  | 		$this->load->library('pdf'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 979 |  |  | 		$this->fpdf = new PDF('P', 'pt'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 980 |  |  | 		$this->fpdf->initialize('P', 'mm', 'A4'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 981 |  |  | 		$this->fpdf->tablewidths = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 982 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 983 |  |  | 			30, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 984 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 985 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 986 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 987 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 988 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 989 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 990 |  |  | 			20 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 991 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 992 |  |  | 		$outbound_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 993 |  |  | 			"Code", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 994 |  |  | 			"Destination", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 995 |  |  | 			"Connect Cost", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 996 |  |  | 			"Included Seconds", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 997 |  |  | 			"Per Minute Cost", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 998 |  |  | 			"Initial Increment", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 999 |  |  | 			"Increment", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1000 |  |  | 			"Precedence", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1001 |  |  | 			"Prepend", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1002 |  |  | 			"Strip" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1003 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1004 |  |  | 		if ($query->num_rows() > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1005 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1006 |  |  | 			foreach($query->result_array() as $row) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1007 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1008 |  |  | 				$outbound_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1009 |  |  | 					$row['pattern'] = $this->common->get_only_numeric_val("", "", $row["pattern"]) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1010 |  |  | 					$row['comment'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1011 |  |  | 					$row['connectcost'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1012 |  |  | 					$row['includedseconds'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1013 |  |  | 					$this->common_model->calculate_currency($row['cost']) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1014 |  |  | 					/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1015 |  |  | 					 ASTPP  3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1016 |  |  | 					 For Add Initial Increment field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1017 |  |  | 					 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1018 |  |  | 					 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1019 |  |  | 					$row['init_inc'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1020 |  |  | 					/*******************************************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1021 |  |  | 					$row['inc'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1022 |  |  | 					$row['precedence'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1023 |  |  | 					$row['prepend'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1024 |  |  | 					$row['strip'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1025 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1026 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1027 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1028 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1029 |  |  | 		$this->fpdf->AliasNbPages(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1030 |  |  | 		$this->fpdf->AddPage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1031 |  |  | 		$this->fpdf->SetFont('Arial', '', 15); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1032 |  |  | 		$this->fpdf->SetXY(60, 5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1033 |  |  | 		$this->fpdf->Cell(100, 10, "Outbound Rates Report " . date('Y-m-d')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1034 |  |  | 		$this->fpdf->SetY(20); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1035 |  |  | 		$this->fpdf->SetFont('Arial', '', 7); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1036 |  |  | 		$this->fpdf->SetFillColor(255, 255, 255); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1037 |  |  | 		$this->fpdf->lMargin = 2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1038 |  |  | 		$dimensions = $this->fpdf->export_pdf($outbound_array, "7"); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1039 |  |  | 		$this->fpdf->Output('Termination_Rate_' . date("Y-m-d") . '.pdf', "D"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1040 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1041 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1042 |  |  | 	function origination_rate_export_cdr_xls() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1043 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1044 |  |  | 		$account_info = $accountinfo = $this->session->userdata('accountinfo'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1045 |  |  | 		$currency_id = $account_info['currency_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1046 |  |  | 		$currency = $this->common->get_field_name('currency', 'currency', $currency_id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1047 |  |  | 		$query = $this->rates_model->get_origination_rate(true, '', '', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1048 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1049 |  |  | 		// echo "<pre>";print_r($query);exit; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1050 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1051 |  |  | 		$inbound_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1052 |  |  | 		ob_clean(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1053 |  |  | 		$inbound_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1054 |  |  | 			"Code", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1055 |  |  | 			"Destination", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1056 |  |  | 			"Connect Cost($currency)", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1057 |  |  | 			"Included Seconds", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1058 |  |  | 			"Per Minute Cost($currency)", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1059 |  |  | 			"Initial Increment", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1060 |  |  | 			"Increment", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1061 |  |  | 			"Rate Group", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1062 |  |  | 			"Status", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1063 |  |  | 			"Created Date" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1064 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1065 |  |  | 		if ($query->num_rows() > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1066 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1067 |  |  | 			foreach($query->result_array() as $row) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1068 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1069 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1070 |  |  | 				// echo"<pre>";print_r($row);exit; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1071 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1072 |  |  | 				$inbound_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1073 |  |  | 					$row['pattern'] = $this->common->get_only_numeric_val("", "", $row["pattern"]) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1074 |  |  | 					$row['comment'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1075 |  |  | 					$this->common_model->calculate_currency($row['connectcost'], '', '', TRUE, false) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1076 |  |  | 					$row['includedseconds'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1077 |  |  | 					$this->common_model->calculate_currency($row['cost'], '', '', TRUE, false) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1078 |  |  | 					/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1079 |  |  | 					 ASTPP  3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1080 |  |  | 					 For Add Initial Increment field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1081 |  |  | 					 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1082 |  |  | 					 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1083 |  |  | 					$row['init_inc'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1084 |  |  | 					/********************************************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1085 |  |  | 					$row['inc'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1086 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1087 |  |  | 					// $row['precedence'], | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1088 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1089 |  |  | 					$this->common->get_field_name('name', 'pricelists', $row['pricelist_id']) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1090 |  |  | 					$this->common->get_status('export', '', $row['status']) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1091 |  |  | 					$row['creation_date'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1092 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1093 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1094 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1095 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1096 |  |  | 		$this->load->helper('csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1097 |  |  | 		array_to_csv($inbound_array, 'Origination_Rates_' . date("Y-m-d") . '.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1098 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1099 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1100 |  |  | 	function origination_rate_export_cdr_pdf() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1101 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1102 |  |  | 		$query = $this->rates_model->get_origination_rate(true, '', '', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1103 |  |  | 		$inbound_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1104 |  |  | 		$this->load->library('fpdf'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1105 |  |  | 		$this->load->library('pdf'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1106 |  |  | 		$this->fpdf = new PDF('P', 'pt'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1107 |  |  | 		$this->fpdf->initialize('P', 'mm', 'A4'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1108 |  |  | 		$this->fpdf->tablewidths = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1109 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1110 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1111 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1112 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1113 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1114 |  |  | 			20 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1115 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1116 |  |  | 		$inbound_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1117 |  |  | 			"Code", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1118 |  |  | 			"Destination", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1119 |  |  | 			"Connect Cost", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1120 |  |  | 			"Included Seconds", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1121 |  |  | 			"Per Minute Cost", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1122 |  |  | 			"Initial Increment", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1123 |  |  | 			"Increment" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1124 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1125 |  |  | 		if ($query->num_rows() > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1126 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1127 |  |  | 			foreach($query->result_array() as $row) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1128 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1129 |  |  | 				$inbound_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1130 |  |  | 					$row['pattern'] = $this->common->get_only_numeric_val("", "", $row["pattern"]) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1131 |  |  | 					$row['comment'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1132 |  |  | 					$row['connectcost'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1133 |  |  | 					$row['includedseconds'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1134 |  |  | 					$this->common_model->calculate_currency($row['cost'], '', '', '', false) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1135 |  |  | 					/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1136 |  |  | 					 ASTPP  3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1137 |  |  | 					 For Add Initial Increment field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1138 |  |  | 					 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1139 |  |  | 					 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1140 |  |  | 					$row['init_inc'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1141 |  |  | 					/*************************************************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1142 |  |  | 					$row['inc'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1143 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1144 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1145 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1146 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1147 |  |  | 		$this->fpdf->AliasNbPages(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1148 |  |  | 		$this->fpdf->AddPage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1149 |  |  | 		$this->fpdf->SetFont('Arial', '', 15); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1150 |  |  | 		$this->fpdf->SetXY(60, 5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1151 |  |  | 		$this->fpdf->Cell(100, 10, "Origination Rates Report " . date('Y-m-d')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1152 |  |  | 		$this->fpdf->SetY(20); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1153 |  |  | 		$this->fpdf->SetFont('Arial', '', 7); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1154 |  |  | 		$this->fpdf->SetFillColor(255, 255, 255); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1155 |  |  | 		$this->fpdf->lMargin = 2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1156 |  |  | 		$dimensions = $this->fpdf->export_pdf($inbound_array, "5"); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1157 |  |  | 		$this->fpdf->Output('Origination_Rate_' . date("Y-m-d") . '.pdf', "D"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1158 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1160 |  |  | 	function user_origination_rate_cdr_pdf() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1161 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1162 |  |  | 		$query = $this->rates_model->get_origination_rate_for_user(true, '', '', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1163 |  |  | 		$inbound_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1164 |  |  | 		$this->load->library('fpdf'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1165 |  |  | 		$this->load->library('pdf'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1166 |  |  | 		$this->fpdf = new PDF('P', 'pt'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1167 |  |  | 		$this->fpdf->initialize('P', 'mm', 'A4'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1168 |  |  | 		$this->fpdf->tablewidths = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1169 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1170 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1171 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1172 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1173 |  |  | 			20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1174 |  |  | 			20 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1175 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1176 |  |  | 		$inbound_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1177 |  |  | 			"Code", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1178 |  |  | 			"Destination", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1179 |  |  | 			"Increment", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1180 |  |  | 			"Cost Per Minutes", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1181 |  |  | 			"Connect Charge", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1182 |  |  | 			"Included Seconds" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1183 |  |  | 		); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1184 |  | View Code Duplication | 		if ($query->num_rows() > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1185 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1186 |  |  | 			foreach($query->result_array() as $row) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1187 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1188 |  |  | 				$inbound_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1189 |  |  | 					$row['pattern'] = $this->common->get_only_numeric_val("", "", $row["pattern"]) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1190 |  |  | 					$row['comment'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1191 |  |  | 					$row['inc'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1192 |  |  | 					$this->common_model->calculate_currency($row['cost'], '', '', '', false) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1193 |  |  | 					$row['connectcost'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1194 |  |  | 					$row['includedseconds'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1195 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1196 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1197 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1198 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1199 |  |  | 		$this->fpdf->AliasNbPages(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1200 |  |  | 		$this->fpdf->AddPage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1201 |  |  | 		$this->fpdf->SetFont('Arial', '', 15); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1202 |  |  | 		$this->fpdf->SetXY(60, 5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1203 |  |  | 		$this->fpdf->Cell(100, 10, "Rates Report " . date('Y-m-d')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1204 |  |  | 		$this->fpdf->SetY(20); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1205 |  |  | 		$this->fpdf->SetFont('Arial', '', 7); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1206 |  |  | 		$this->fpdf->SetFillColor(255, 255, 255); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1207 |  |  | 		$this->fpdf->lMargin = 2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1208 |  |  | 		$dimensions = $this->fpdf->export_pdf($inbound_array, "5"); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1209 |  |  | 		$this->fpdf->Output('Rates_' . date("Y-m-d") . '.pdf', "D"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1210 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1212 |  |  | 	function resellersrates_list() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1213 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1214 |  |  | 		$accountinfo = $this->session->userdata('accountinfo'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1215 |  |  | 		$data['username'] = $this->session->userdata('user_name'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1216 |  |  | 		$data['page_title'] = 'My Rates'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1217 |  |  | 		$data['search_flag'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1218 |  |  | 		$this->session->set_userdata('advance_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1219 |  |  | 		$data['grid_fields'] = $this->rates_form->build_rates_list_for_reseller(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1220 |  |  | 		$data["grid_buttons"] = $this->rates_form->build_grid_buttons_rates(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1221 |  |  | 		$data['form_search'] = $this->form->build_serach_form($this->rates_form->get_reseller_origination_rate_search_form()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1222 |  |  | 		$this->load->view('view_resellersrates_list', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1223 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1224 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1225 |  |  | 	function resellersrates_list_json() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1226 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1227 |  |  | 		$json_data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1228 |  |  | 		$account_data = $this->session->userdata("accountinfo"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1229 |  |  | 		$markup = $this->common->get_field_name('markup', 'pricelists', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1230 |  |  | 			'id' => $account_data["pricelist_id"] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1231 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1233 |  |  | 		// $markup = ($markup > 0)?$markup:1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1234 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1235 |  |  | 		$count_all = $this->rates_model->getreseller_rates_list(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1236 |  |  | 		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1237 |  |  | 		$json_data = $paging_data["json_paging"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1238 |  |  | 		$query = $this->rates_model->getreseller_rates_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1239 |  |  | 		$grid_fields = json_decode($this->rates_form->build_rates_list_for_reseller()); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1240 |  | View Code Duplication | 		foreach($query->result_array() as $key => $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1241 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1242 |  |  | 			$json_data['rows'][] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1243 |  |  | 				'cell' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1244 |  |  | 					$this->common->get_only_numeric_val("", "", $value["pattern"]) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1245 |  |  | 					$value['comment'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1246 |  |  | 					$this->common_model->calculate_currency($value['connectcost'], '', '', 'true', true) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1247 |  |  | 					$value['includedseconds'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1248 |  |  | 					$this->common_model->calculate_currency(($value['cost'] + ($value['cost'] * $markup) / 100) , '', '', 'true', true) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1249 |  |  | 					$value['inc'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1250 |  |  | 					$value['precedence'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1251 |  |  | 				) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1252 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1253 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1254 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1255 |  |  | 		//        $json_data['rows'] = $this->form->build_grid($query, $grid_fields); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1256 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1257 |  |  | 		echo json_encode($json_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1258 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1259 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1260 |  | View Code Duplication | 	function resellersrates_list_search() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1261 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1262 |  |  | 		$ajax_search = $this->input->post('ajax_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1263 |  |  | 		if ($this->input->post('advance_search', TRUE) == 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1264 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1265 |  |  | 			$this->session->set_userdata('advance_search', $this->input->post('advance_search')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1266 |  |  | 			$action = $this->input->post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1267 |  |  | 			unset($action['action']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1268 |  |  | 			unset($action['advance_search']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1269 |  |  | 			$this->session->set_userdata('resellerrates_list_search', $action); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1270 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1271 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1272 |  |  | 		if (@$ajax_search != 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1273 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1274 |  |  | 			redirect(base_url() . 'rates/resellersrates_list/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1275 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1276 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1278 |  |  | 	function resellersrates_list_clearsearchfilter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1279 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1280 |  |  | 		$this->session->set_userdata('advance_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1281 |  |  | 		$this->session->set_userdata('resellerrates_list_search', ""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1282 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1284 |  |  | 	function resellersrates_xls() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1285 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1286 |  |  | 		$account_info = $accountinfo = $this->session->userdata('accountinfo'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1287 |  |  | 		$currency_id = $account_info['currency_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1288 |  |  | 		$currency = $this->common->get_field_name('currency', 'currency', $currency_id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1289 |  |  | 		$query = $this->rates_model->getreseller_rates_list(true, '0', '0', '1'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1290 |  |  | 		$customer_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1291 |  |  | 		ob_clean(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1292 |  |  | 		$customer_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1293 |  |  | 			"Code", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1294 |  |  | 			"Destination", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1295 |  |  | 			"Connect Cost($currency)", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1296 |  |  | 			"Included Seconds", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1297 |  |  | 			"Per Minute Cost($currency)", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1298 |  |  | 			"Increment", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1299 |  |  | 			"Precedence" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1300 |  |  | 		); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1301 |  | View Code Duplication | 		if ($query->num_rows() > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1302 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1303 |  |  | 			foreach($query->result_array() as $row) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1304 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1305 |  |  | 				$customer_array[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1306 |  |  | 					$row['pattern'] = $this->common->get_only_numeric_val("", "", $row["pattern"]) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1307 |  |  | 					$row['comment'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1308 |  |  | 					$row['connectcost'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1309 |  |  | 					$row['includedseconds'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1310 |  |  | 					$this->common_model->calculate_currency($row['cost']) , | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1311 |  |  | 					$row['inc'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1312 |  |  | 					$row['precedence'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1313 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1314 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1315 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1317 |  |  | 		$this->load->helper('csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1318 |  |  | 		array_to_csv($customer_array, 'My_Own_Rate_' . date("Y-m-d") . '.csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1319 |  |  | 		exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1320 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1321 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1322 |  |  | 	/*********** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1323 |  |  | 	ASTPP  3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1324 |  |  | 	Batch delete | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1325 |  |  | 	***********/ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1326 |  | View Code Duplication | 	function termination_rates_list_batch_delete() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1327 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1328 |  |  | 		$ajax_search = $this->input->post('ajax_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1329 |  |  | 		if ($this->input->post('advance_search', TRUE) == 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1330 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1331 |  |  | 			$this->session->set_userdata('advance_batch_delete', $this->input->post('advance_search')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1332 |  |  | 			$action = $this->input->post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1333 |  |  | 			unset($action['action']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1334 |  |  | 			unset($action['advance_search']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1335 |  |  | 			$this->session->set_userdata('termination_rates_list_search', $action); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1336 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1337 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1338 |  |  | 		if (@$ajax_search != 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1339 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1340 |  |  | 			redirect(base_url() . 'rates/termination_rates_list/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1341 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1342 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1343 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1344 |  | View Code Duplication | 	function origination_rates_list_batch_delete() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1345 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1346 |  |  | 		$ajax_search = $this->input->post('ajax_search', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1347 |  |  | 		if ($this->input->post('advance_search', TRUE) == 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1348 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1349 |  |  | 			$this->session->set_userdata('advance_batch_delete', $this->input->post('advance_search')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1350 |  |  | 			$action = $this->input->post(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1351 |  |  | 			unset($action['action']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1352 |  |  | 			unset($action['advance_search']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1353 |  |  | 			$this->session->set_userdata('origination_rate_list_search', $action); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1354 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1355 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1356 |  |  | 		if (@$ajax_search != 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1357 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1358 |  |  | 			redirect(base_url() . 'rates/origination_rates_list/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1359 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1360 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1361 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1362 |  |  | 	/*************************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1363 |  |  | 	/********* Import Mapper Code - ISSUE-142 **********/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1364 |  |  | 	function termination_rate_import_mapper() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1365 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1366 |  |  | 		$data['page_title'] = 'Import Termination Rates using field mapper'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1367 |  |  | 		$this->session->set_userdata('import_termination_rate_mapper_csv', ""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1368 |  |  | 		$this->session->set_userdata('import_termination_rate_mapper_csv_error', ""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1369 |  |  | 		$this->load->view('view_import_termination_rate_mapper', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1370 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1371 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1372 |  |  | 	function csv_to_array($filename = '', $delimiter = ',') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1373 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1374 |  |  | 		if (!file_exists($filename) || !is_readable($filename)) return FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1375 |  |  | 		$header = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1376 |  |  | 		$data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1377 |  |  | 		if (($handle = fopen($filename, 'r')) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1378 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1379 |  |  | 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1380 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1381 |  |  | 				if (!$header) $header = $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1382 |  |  | 				else $data[] = array_combine($header, $row); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1383 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1384 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1385 |  |  | 			fclose($handle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1386 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1387 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1388 |  |  | 		return $data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1389 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1390 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1391 |  |  | 	function utf8_converter($array) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1392 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1393 |  |  | 		array_walk_recursive($array, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1394 |  |  | 		function (&$item, $key) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1395 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1396 |  |  | 			if (!mb_detect_encoding($item, 'utf-8', true)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1397 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1398 |  |  | 				$item = utf8_encode($item); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1399 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1400 |  |  | 		}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1401 |  |  | 		return $array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1402 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1403 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1404 |  |  | 	function termination_rate_mapper_preview_file() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1405 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1406 |  |  | 		$invalid_flag = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1407 |  |  | 		$check_header = $this->input->post('check_header', true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1408 |  |  | 		$data['page_title'] = 'Import Termination Rates using field mapper'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1409 |  |  | 		$new_final_arr_key = $this->config->item('Termination-rates-field'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1410 |  |  | 		if (empty($_FILES) || !isset($_FILES)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1411 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1412 |  |  | 			redirect(base_url() . "rates/termination_rates_list/"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1413 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1414 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1415 |  |  | 		$data['mapto_fields'] = $new_final_arr_key; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1416 |  |  | 		if (isset($_FILES['termination_rate_import_mapper']['name']) && $_FILES['termination_rate_import_mapper']['name'] != "" && isset($_POST['trunk_id']) && $_POST['trunk_id'] != '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1417 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1418 |  |  | 			list($txt, $ext) = explode(".", $_FILES['termination_rate_import_mapper']['name']); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1419 |  |  | 			if ($ext == "csv" && $_FILES['termination_rate_import_mapper']['size'] > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1420 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1421 |  |  | 				$error = $_FILES['termination_rate_import_mapper']['error']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1422 |  |  | 				if ($error == 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1423 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1424 |  |  | 					$uploadedFile = $_FILES["termination_rate_import_mapper"]["tmp_name"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1425 |  |  | 					$file_data = $this->csv_to_array($uploadedFile); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1426 |  |  | 					$field_select = (array_keys($file_data[0])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1427 |  |  | 					$data['file_data'] = $field_select; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1428 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1429 |  |  | 					// $csv_data = $this->csvreader->parse_file($uploadedFile, $new_final_arr_key, $check_header); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1430 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1431 |  |  | 					$csv_data = $this->utf8_converter($this->csvreader->parse_file($uploadedFile, $field_select, $check_header)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1432 |  |  |         			if (!empty($csv_data)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1433 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1434 |  |  | 						$full_path = $this->config->item('rates-file-path'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1435 |  |  | 						$actual_file_name = "ASTPP-TERMINATION-RATES-" . date("Y-m-d H:i:s") . "." . $ext; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1436 |  |  | 						$actual_file_name = str_replace(' ', '-', $actual_file_name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1437 |  |  | 						$actual_file_name = str_replace(':', '-', $actual_file_name); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1438 |  | View Code Duplication | 						if (move_uploaded_file($uploadedFile, $full_path . $actual_file_name)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1439 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1440 |  |  | 							$data['field_select'] = serialize($field_select); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1441 |  |  | 							$data['csv_tmp_data'] = $csv_data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1442 |  |  | 							$data['trunkid'] = $_POST['trunk_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1443 |  |  | 							$data['check_header'] = $check_header; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1444 |  |  | 							$data['page_title'] = 'Map CSV to Termination Rates'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1445 |  |  | 							$this->session->set_userdata('import_termination_rate_mapper_csv', $actual_file_name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1446 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1447 |  |  | 						else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1448 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1449 |  |  | 							$data['error'] = "File Uploading Fail Please Try Again"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1450 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1451 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1452 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1453 |  |  | 				else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1454 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1455 |  |  | 					$data['error'] == "File Uploading Fail Please Try Again"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1456 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1457 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1458 |  |  | 			else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1459 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1460 |  |  | 				$data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1461 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1462 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1463 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1464 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1465 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1466 |  |  | 			$invalid_flag = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1467 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1468 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1469 |  |  | 		if ($invalid_flag) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1470 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1472 |  |  | 			$str = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1473 |  |  | 			if (!isset($_POST['trunk_id']) || empty($_POST['trunk_id'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1474 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1475 |  |  | 				$str.= '<br/>Please Create Trunk.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1476 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1477 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1478 |  |  | 			if (empty($_FILES['termination_rate_import_mapper']['name'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1479 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1480 |  |  | 				$str.= '<br/>Please Select File.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1481 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1482 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1483 |  |  | 			$data['error'] = $str; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1484 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1485 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1486 |  |  | 		$this->load->view('view_import_termination_rate_mapper', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1487 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1488 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1489 |  |  | 	function termination_rate_rates_mapper_import() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1490 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1491 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1492 |  |  | 		// var_dump($this->input->post()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1493 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1494 |  |  | 		$trunkID = $this->input->post("trunkid"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1495 |  |  | 		$check_header = $this->input->post("check_header"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1496 |  |  | 		$pattern_prefix = $this->input->post("pattern-prefix"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1497 |  |  | 		$filefields = unserialize($this->input->post("filefields")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1498 |  |  | 		$new_final_arr = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1499 |  |  | 		$invalid_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1500 |  |  | 		$new_final_arr_key = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1501 |  |  | 		foreach($filefields as $item) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1502 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1503 |  |  | 			$new_final_arr_key[$item] = $item; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1504 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1505 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1506 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1507 |  |  | 		$screen_path = $this->config->item('screen_path'); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1508 |  | View Code Duplication | 		if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1509 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1510 |  |  | 			$account_data = $this->session->userdata("accountinfo"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1511 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1512 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1513 |  |  | 		$full_path = $this->config->item('rates-file-path'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1514 |  |  | 		$terminationrate_file_name = $this->session->userdata('import_termination_rate_mapper_csv'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1515 |  |  | 		$csv_tmp_data = $this->csvreader->parse_file($full_path . $terminationrate_file_name, $new_final_arr_key, $check_header); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1516 |  |  | 		$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1517 |  |  | 		foreach($csv_tmp_data as $key => $csv_data) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1518 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1519 |  |  | 			if (isset($csv_data[$this->input->post("pattern-select") ]) && $csv_data[$this->input->post("pattern-select") ] != '' && $i != 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1520 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1521 |  |  | 				$str = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1522 |  |  | 				$csv_data['pattern'] = ($this->input->post("pattern-prefix")) ? $this->input->post("pattern-prefix") . $csv_data[$this->input->post("pattern-select") ] : $csv_data[$this->input->post("pattern-select") ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1523 |  |  | 				$csv_data['cost'] = ($this->input->post("cost-select")) ? $csv_data[$this->input->post("cost-select") ] : ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1524 |  |  | 				$csv_data['cost'] = ($this->input->post("cost-prefix")) ? $this->input->post("cost-prefix") . $csv_data['cost'] : $csv_data['cost']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1525 |  |  | 				$csv_data['prepend'] = ($this->input->post("prepend-select")) ? $csv_data[$this->input->post("prepend-select") ] : ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1526 |  |  | 				$csv_data['prepend'] = ($this->input->post("prepend-prefix")) ? $this->input->post("prepend-prefix") . $csv_data['prepend'] : $csv_data['prepend']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1527 |  |  | 				$csv_data['comment'] = ($this->input->post("comment-select")) ? $csv_data[$this->input->post("comment-select") ] : ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1528 |  |  | 				$csv_data['comment'] = ($this->input->post("comment-prefix")) ? $this->input->post("comment-prefix") . $csv_data['comment'] : $csv_data['comment']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1529 |  |  | 				$csv_data['connectcost'] = ($this->input->post("connectcost-select")) ? $csv_data[$this->input->post("connectcost-select") ] : "0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1530 |  |  | 				$csv_data['connectcost'] = ($this->input->post("connectcost-prefix")) ? $this->input->post("connectcost-prefix") . $csv_data['connectcost'] : $csv_data['connectcost']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1531 |  |  | 				$csv_data['includedseconds'] = ($this->input->post("includedseconds-select")) ? $csv_data[$this->input->post("includedseconds-select") ] : "0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1532 |  |  | 				$csv_data['includedseconds'] = ($this->input->post("includedseconds-prefix")) ? $this->input->post("includedseconds-prefix") . $csv_data['includedseconds'] : $csv_data['includedseconds']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1533 |  |  | 				$csv_data['inc'] = ($this->input->post("inc-select")) ? $csv_data[$this->input->post("inc-select") ] : "0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1534 |  |  | 				$csv_data['inc'] = ($this->input->post("inc-prefix")) ? $this->input->post("inc-prefix") . $csv_data['inc'] : $csv_data['inc']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1535 |  |  | 				$csv_data['precedence'] = ($this->input->post("precedence-select")) ? $csv_data[$this->input->post("precedence-select") ] : ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1536 |  |  | 				$csv_data['precedence'] = ($this->input->post("precedence-prefix")) ? $this->input->post("precedence-prefix") . $csv_data['precedence'] : $csv_data['precedence']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1537 |  |  | 				$csv_data['strip'] = ($this->input->post("strip-select")) ? $csv_data[$this->input->post("strip-select") ] : ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1538 |  |  | 				$csv_data['strip'] = ($this->input->post("strip-prefix")) ? $this->input->post("strip-prefix") . $csv_data['strip'] : $csv_data['strip']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1539 |  |  | 				$csv_data['last_modified_date'] = date("Y-m-d H:i:s"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1540 |  |  | 				$str = $this->data_validate($csv_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1541 |  |  | 				if ($str != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1542 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1543 |  |  | 					$invalid_array[$i] = $csv_data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1544 |  |  | 					$invalid_array[$i]['error'] = $str; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1545 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1546 |  |  | 				else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1547 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1548 |  |  | 					$new_final_arr[$i]['trunk_id'] = $trunkID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1549 |  |  | 					$new_final_arr[$i]['pattern'] = "^" . $csv_data['pattern'] . ".*"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1550 |  |  | 					$new_final_arr[$i]['prepend'] = $csv_data['prepend']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1551 |  |  | 					$new_final_arr[$i]['last_modified_date'] = $csv_data['last_modified_date']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1552 |  |  | 					$new_final_arr[$i]['comment'] = $csv_data['comment']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1553 |  |  | 					$new_final_arr[$i]['connectcost'] = $csv_data['connectcost']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1554 |  |  | 					$new_final_arr[$i]['includedseconds'] = $csv_data['includedseconds']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1555 |  |  | 					$new_final_arr[$i]['cost'] = !empty($csv_data['cost']) && is_numeric($csv_data['cost']) ? $csv_data['cost'] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1556 |  |  | 					$new_final_arr[$i]['inc'] = isset($csv_data['inc']) ? $csv_data['inc'] : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1557 |  |  | 					$new_final_arr[$i]['precedence'] = isset($csv_data['precedence']) ? $csv_data['precedence'] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1558 |  |  | 					$new_final_arr[$i]['strip'] = isset($csv_data['strip']) ? $csv_data['strip'] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1559 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1560 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1561 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1562 |  |  | 			$i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1563 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1564 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1565 |  |  | 		if (!empty($new_final_arr)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1566 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1567 |  |  | 			$result = $this->rates_model->bulk_insert_termination_rate($new_final_arr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1568 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1569 |  |  |         		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1570 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1571 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1572 |  |  |            $this->session->set_flashdata('astpp_errormsg', 'Error - Nothing selected to import/process!'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1573 |  |  |            redirect(base_url() . 'rates/termination_rates_list/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1574 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1575 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1576 |  |  | 		unlink($full_path . $terminationrate_file_name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1577 |  |  | 		$count = count($invalid_array); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1578 |  | View Code Duplication | 		if ($count > 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1579 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1580 |  |  | 			$session_id = "-1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1581 |  |  | 			$fp = fopen($full_path . $session_id . '.csv', 'w'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1582 |  |  | 			foreach($new_final_arr_key as $key => $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1583 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1584 |  |  | 				$custom_array[0][$key] = ucfirst($key); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1585 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1586 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1587 |  |  | 			$custom_array[0]['error'] = "Error"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1588 |  |  | 			$invalid_array = array_merge($custom_array, $invalid_array); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1589 |  |  | 			foreach($invalid_array as $err_data) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1590 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1591 |  |  | 				fputcsv($fp, $err_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1592 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1593 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1594 |  |  | 			fclose($fp); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1595 |  |  | 			$this->session->set_userdata('import_termination_rate_mapper_csv_error', $session_id . ".csv"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1596 |  |  | 			$data["error"] = $invalid_array; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1597 |  |  | 			$data['trunkid'] = $trunkID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1598 |  |  | 			$data['impoted_count'] = count($new_final_arr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1599 |  |  | 			$data['failure_count'] = count($invalid_array) - 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1600 |  |  | 			$data['page_title'] = 'Termination Rates Import Error'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1601 |  |  | 			$this->load->view('view_import_error', $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1602 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1603 |  |  | 		else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1604 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1605 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1606 |  |  | 			$this->session->set_flashdata('astpp_errormsg', 'Total ' . count($new_final_arr) . ' Termination rates imported successfully!'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1607 |  |  | 			redirect(base_url() . 'rates/termination_rates_list/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1608 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1609 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1610 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1611 |  |  | 	/*************************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1612 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1613 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 1614 |  |  | ?> | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 1615 |  |  |   | 
            
                        
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.