Code Duplication    Length = 22-30 lines in 2 locations

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

@@ 368-397 (lines=30) @@
365
		if (isset($_FILES['package_code_import']['name']) && $_FILES['package_code_import']['name'] != "" ) {
366
			list($txt,$ext) = explode(".", $_FILES['package_code_import']['name']);
367
            
368
			if($ext == "csv" && $_FILES['package_code_import']['size'] > 0){ 
369
				$error = $_FILES['package_code_import']['error'];
370
				if ($error == 0) {
371
					$uploadedFile = $_FILES["package_code_import"]["tmp_name"];
372
					$csv_data=$this->csvreader->parse_file($uploadedFile,$new_final_arr_key,$check_header);
373
					if(!empty($csv_data)){
374
			$full_path = $this->config->item('rates-file-path');
375
			//echo "<pre>";print_r($full_path);exit;
376
					$actual_file_name = "ASTPP-ORIGIN-RATES-".date("Y-m-d H:i:s"). "." . $ext;
377
					//echo "<pre>";print_r($actual_file_name);exit;
378
					if (move_uploaded_file($uploadedFile,$full_path.$actual_file_name)) {
379
			$flag=false;
380
			//$data['trunkid']=isset($_POST['trunk_id']) && $_POST['trunk_id'] > 0 ? $_POST['trunk_id'] : 0;
381
						$data['csv_tmp_data'] = $csv_data;
382
						//$data['pricelistid'] = $_POST['pricelist_id'];
383
						$data['page_title'] = "Package Patterns Preview";
384
						$data['check_header']=$check_header;
385
						$this->session->set_userdata('import_package_code_csv',$actual_file_name);
386
					}else{
387
						$data['error'] = "File Uploading Fail Please Try Again";
388
					}
389
				}
390
			 }   
391
			else{
392
					$data['error']=="File Uploading Fail Please Try Again";
393
				}
394
		   }
395
		   else {
396
				$data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)";
397
			}
398
			}else{
399
		$invalid_flag=true;
400
			}

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

@@ 241-262 (lines=22) @@
238
            
239
			if($ext == "csv" && $_FILES['origination_rate_import']['size'] > 0){ 
240
				$error = $_FILES['origination_rate_import']['error'];
241
				if ($error == 0) {
242
					$uploadedFile = $_FILES["origination_rate_import"]["tmp_name"];
243
					$csv_data=$this->csvreader->parse_file($uploadedFile,$new_final_arr_key,$check_header);
244
					if(!empty($csv_data)){
245
			$full_path = $this->config->item('rates-file-path');
246
					$actual_file_name = "ASTPP-ORIGIN-RATES-".date("Y-m-d H:i:s"). "." . $ext;
247
					if (move_uploaded_file($uploadedFile,$full_path.$actual_file_name)) {
248
			$flag=false;
249
			$data['trunkid']=isset($_POST['trunk_id']) && $_POST['trunk_id'] > 0 ? $_POST['trunk_id'] : 0;
250
						$data['csv_tmp_data'] = $csv_data;
251
						$data['pricelistid'] = $_POST['pricelist_id'];
252
						$data['page_title'] = "Origination Rates Preview";
253
						$data['check_header']=$check_header;
254
						$this->session->set_userdata('import_origination_rate_csv',$actual_file_name);
255
					}else{
256
						$data['error'] = "File Uploading Fail Please Try Again";
257
					}
258
				}
259
			 }   
260
			else{
261
					$data['error']=="File Uploading Fail Please Try Again";
262
				}
263
		   }
264
		   else {
265
				$data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)";