Code Duplication    Length = 23-25 lines in 3 locations

web_interface/astpp/application/modules/package/controllers/package.php 1 location

@@ 472-496 (lines=25) @@
469
	   //unlink($full_path.$originationrate_file_name);
470
	 $count=count($invalid_array);
471
	 //echo "<pre>";print_r($count);exit;
472
		if($count >0){
473
			$session_id = "-1";
474
			$fp = fopen($full_path.$session_id.'.csv', 'w');
475
			foreach($new_final_arr_key as $key=>$value){
476
		  $custom_array[0][$key]=ucfirst($key);
477
			}
478
			$custom_array[0]['error']= "Error";
479
			$invalid_array =array_merge($custom_array,$invalid_array);
480
			foreach($invalid_array as $err_data){
481
					fputcsv($fp,$err_data);
482
			}
483
			fclose($fp);
484
		   $this->session->set_userdata('import_package_code_csv_error', $session_id.".csv");
485
		   $data["error"] = $invalid_array;
486
		   $data['packageid'] = $edit_id;
487
		   $data['impoted_count'] = count($new_final_arr);
488
		   $data['failure_count'] = count($invalid_array)-1;
489
		   $data['page_title'] = 'Package Patterns Import Error';
490
		   //print_r($data)	;exit;
491
		   $this->load->view('view_import_error',$data);
492
		 } else{
493
	   $this->session->set_flashdata('astpp_errormsg', 'Package patterns imported successfully!');
494
	   //echo base_url()."package/package_pattern_list/" . $edit_id . "/";exit;
495
		   redirect(base_url()."package/package_pattern_list/" . $edit_id . "/");
496
		   }
497
	}
498
    
499
	  function data_validate($csvdata){

web_interface/astpp/application/modules/rates/controllers/rates.php 2 locations

@@ 180-202 (lines=23) @@
177
		 }
178
		  unlink($full_path.$terminationrate_file_name);
179
	  $count=count($invalid_array);
180
		if($count >0){
181
			$session_id = "-1";
182
			$fp = fopen($full_path.$session_id.'.csv', 'w');
183
			foreach($new_final_arr_key as $key=>$value){
184
		  $custom_array[0][$key]=ucfirst($key);
185
			}
186
			$custom_array[0]['error']= "Error";
187
			$invalid_array =array_merge($custom_array,$invalid_array);
188
			foreach($invalid_array as $err_data){
189
					fputcsv($fp,$err_data);
190
			}
191
		   fclose($fp);
192
		   $this->session->set_userdata('import_termination_rate_csv_error', $session_id.".csv");
193
		   $data["error"] = $invalid_array;
194
		   $data['trunkid'] = $trunkID;
195
		   $data['impoted_count'] = count($new_final_arr);
196
		   $data['failure_count'] = count($invalid_array)-1;
197
		   $data['page_title'] = 'Termination Rates Import Error';	
198
		   $this->load->view('view_import_error',$data);
199
		 } else{
200
	  $this->session->set_flashdata('astpp_errormsg', 'Total '.count($new_final_arr).' Termination rates imported successfully!');
201
		   redirect(base_url()."rates/termination_rates_list/");
202
		 }        
203
	}
204
	function termination_rate_error_download(){
205
		$this->load->helper('download');
@@ 328-350 (lines=23) @@
325
		  }
326
		  unlink($full_path.$originationrate_file_name);
327
	 $count=count($invalid_array);
328
		if($count >0){
329
			$session_id = "-1";
330
			$fp = fopen($full_path.$session_id.'.csv', 'w');
331
			foreach($new_final_arr_key as $key=>$value){
332
		  $custom_array[0][$key]=ucfirst($key);
333
			}
334
			$custom_array[0]['error']= "Error";
335
			$invalid_array =array_merge($custom_array,$invalid_array);
336
			foreach($invalid_array as $err_data){
337
					fputcsv($fp,$err_data);
338
			}
339
			fclose($fp);
340
		   $this->session->set_userdata('import_origination_rate_csv_error', $session_id.".csv");
341
		   $data["error"] = $invalid_array;
342
		   $data['pricelistid'] = $pricelistID;
343
		   $data['impoted_count'] = count($new_final_arr);
344
		   $data['failure_count'] = count($invalid_array)-1;
345
		   $data['page_title'] = 'Origination Rates Import Error';	
346
		   $this->load->view('view_import_error',$data);
347
		 } else{
348
	   $this->session->set_flashdata('astpp_errormsg', 'Total '.count($new_final_arr).' Origination rates imported successfully!');
349
		   redirect(base_url()."rates/origination_rates_list/");
350
		   }
351
	}
352
	 function data_validate($csvdata){
353
		  $str=null;