Completed
Pull Request — v3.0 (#146)
by
unknown
53:57 queued 42:42
created
application/modules/rates/views/view_import_termination_rate_mapper.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -7,19 +7,19 @@  discard block
 block discarded – undo
7 7
    });
8 8
 </script> <script type="text/javascript" language="javascript"><?
9 9
    if (isset($mapto_fields) && !empty($mapto_fields)) {
10
-    foreach($mapto_fields as $csv_key => $csv_value) {
11
-    echo '$("#'.$csv_value .'-prefix").live("change", function () {';
12
-    echo 'var select = document.getElementById("'.$csv_value .'-select");';
13
-    echo 'var answer = select.options[select.selectedIndex].value;';
14
-    echo 'document.getElementById("'.$csv_value .'-display").value =  (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];';
15
-    echo '});';
16
-    echo '$("#'.$csv_value .'-select").live("change", function () {';
17
-    echo 'var select = document.getElementById("'.$csv_value .'-select");';
18
-    echo 'var answer = select.options[select.selectedIndex].value;';
19
-    echo 'document.getElementById("'.$csv_value .'-display").value = (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];';
20
-    echo '});';
21
-    }
22
-    }
10
+	foreach($mapto_fields as $csv_key => $csv_value) {
11
+	echo '$("#'.$csv_value .'-prefix").live("change", function () {';
12
+	echo 'var select = document.getElementById("'.$csv_value .'-select");';
13
+	echo 'var answer = select.options[select.selectedIndex].value;';
14
+	echo 'document.getElementById("'.$csv_value .'-display").value =  (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];';
15
+	echo '});';
16
+	echo '$("#'.$csv_value .'-select").live("change", function () {';
17
+	echo 'var select = document.getElementById("'.$csv_value .'-select");';
18
+	echo 'var answer = select.options[select.selectedIndex].value;';
19
+	echo 'document.getElementById("'.$csv_value .'-display").value = (!answer) ? document.getElementById("'.$csv_value .'-prefix").value : document.getElementById("'.$csv_value .'-prefix").value + csv_tmp_data[2][answer];';
20
+	echo '});';
21
+	}
22
+	}
23 23
    ?></script>
24 24
 <?
25 25
    if (isset($csv_tmp_data) && !empty($csv_tmp_data)) {
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
    echo 'var csv_tmp_data = ' . json_encode($csv_tmp_data) . ';';
28 28
    echo '</script>';
29 29
    }
30
-    ?>
30
+	?>
31 31
 <?php
32 32
    endblock() ?>
33 33
 <?php
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
                   <div class="w-box">
51 51
                      <span  style="margin-left:10px; text-align: center;background-color: none;color:#DD191D;">
52 52
                      <?php
53
-                        if (isset($error) && !empty($error)) {
54
-                        	echo $error;
55
-                        } ?>
53
+						if (isset($error) && !empty($error)) {
54
+							echo $error;
55
+						} ?>
56 56
                      </span>
57 57
                      <h3 class="padding-t-10 padding-l-16">You must either select a field from your file OR provide a default value for the following fields:</h3>
58 58
                      <p>Code,Destination,Connect Cost,Included Seconds,Per Minute Cost,Increment,Precedence,Strip,Prepend.</p>
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
                            <label class="col-md-3">Trunk List:</label>
67 67
                            <div class="col-md-8">
68 68
                               <?php
69
-                                 $trunklist = form_dropdown('trunk_id', $this->db_model->build_dropdown("id,name", "trunks", "where_arr", array(
70
-                                 	"status " => "0"
71
-                                 )) , '');
72
-                                 echo $trunklist; ?>
69
+								 $trunklist = form_dropdown('trunk_id', $this->db_model->build_dropdown("id,name", "trunks", "where_arr", array(
70
+								 	"status " => "0"
71
+								 )) , '');
72
+								 echo $trunklist; ?>
73 73
                            </div>
74 74
                         </div>
75 75
 
@@ -134,28 +134,28 @@  discard block
 block discarded – undo
134 134
                   </thead>
135 135
                   <tbody>
136 136
                      <?php
137
-                        foreach($mapto_fields as $csv_key => $csv_value) {
137
+						foreach($mapto_fields as $csv_key => $csv_value) {
138 138
 
139
-                        		echo "<tr>";
140
-                        		echo "<td>" . $csv_key . '(' . $csv_value . ")</td>";
141
-                        		echo "<td><input type='text' name='".$csv_value ."-prefix' id='".$csv_value ."-prefix'></td>";
142
-                        		echo "<td>";
143
-                        		echo "<select name='".$csv_value ."-select' id='".$csv_value ."-select'>";
144
-                        		?>
139
+								echo "<tr>";
140
+								echo "<td>" . $csv_key . '(' . $csv_value . ")</td>";
141
+								echo "<td><input type='text' name='".$csv_value ."-prefix' id='".$csv_value ."-prefix'></td>";
142
+								echo "<td>";
143
+								echo "<select name='".$csv_value ."-select' id='".$csv_value ."-select'>";
144
+								?>
145 145
                      <option value=""></option>
146 146
                      <?php
147
-                        $keys = array_keys($file_data);
148
-                        for ($i = 0; $i < count($file_data); $i++) { ?>
147
+						$keys = array_keys($file_data);
148
+						for ($i = 0; $i < count($file_data); $i++) { ?>
149 149
                      <option value="<?php
150
-                        echo $file_data[$i]; ?>"><?php
151
-                        echo $file_data[$i]; ?></option>
150
+						echo $file_data[$i]; ?>"><?php
151
+						echo $file_data[$i]; ?></option>
152 152
                      <?php
153
-                        }
154
-                        echo "</td>";
155
-                        echo "<td><input type='text' name='".$csv_value ."-display' id='".$csv_value ."-display'></td>";
156
-                        echo "</tr>";
153
+						}
154
+						echo "</td>";
155
+						echo "<td><input type='text' name='".$csv_value ."-display' id='".$csv_value ."-display'></td>";
156
+						echo "</tr>";
157 157
 
158
-                        } ?>
158
+						} ?>
159 159
                   </tbody>
160 160
                </table>
161 161
                <input type="hidden" name="trunkid" value="<?php echo $trunkid ?>" />
@@ -167,30 +167,30 @@  discard block
 block discarded – undo
167 167
                <H2> Import File Data..</H2>
168 168
                <table width="100%" border="1"  class="details_table">
169 169
                   <?php
170
-                     $cnt = 1;
171
-                     foreach($csv_tmp_data as $csv_key => $csv_value) {
172
-                     	if ($csv_key < 15) {
173
-                     		echo "<tr>";
174
-                     		foreach($csv_value as $field_name => $field_val) {
175
-                     			if ($csv_key == 0) {
170
+					 $cnt = 1;
171
+					 foreach($csv_tmp_data as $csv_key => $csv_value) {
172
+					 	if ($csv_key < 15) {
173
+					 		echo "<tr>";
174
+					 		foreach($csv_value as $field_name => $field_val) {
175
+					 			if ($csv_key == 0) {
176 176
 
177
-                     				 echo "<th>".ucfirst($field_val)."</th>";
177
+					 				 echo "<th>".ucfirst($field_val)."</th>";
178 178
 
179
-                     			}
180
-                     			else {
181
-                     				echo "<td class='portlet-content'>" . $field_val . "</td>";
182
-                     				$cnt++;
183
-                     			}
184
-                     		}
179
+					 			}
180
+					 			else {
181
+					 				echo "<td class='portlet-content'>" . $field_val . "</td>";
182
+					 				$cnt++;
183
+					 			}
184
+					 		}
185 185
 
186
-                     		echo "</tr>";
187
-                     	}
188
-                     }
186
+					 		echo "</tr>";
187
+					 	}
188
+					 }
189 189
 
190
-                     echo "<tr><td colspan='" . $cnt . "'>
190
+					 echo "<tr><td colspan='" . $cnt . "'>
191 191
                                             <a href='" . base_url() . "rates/termination_rate_list/'><input type='button' class='btn btn-line-sky pull-right  margin-x-10' value='Back'/></a>
192 192
                                             <input type='submit' class='btn btn-line-parrot pull-right'' id='Process' value='Process Records'/></td></tr>";
193
-                     ?>
193
+					 ?>
194 194
                </table>
195 195
             </form>
196 196
          </div>
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -176,8 +176,7 @@
 block discarded – undo
176 176
 
177 177
                      				 echo "<th>".ucfirst($field_val)."</th>";
178 178
 
179
-                     			}
180
-                     			else {
179
+                     			} else {
181 180
                      				echo "<td class='portlet-content'>" . $field_val . "</td>";
182 181
                      				$cnt++;
183 182
                      			}
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/rates/controllers/rates.php 2 patches
Braces   +45 added lines, -62 removed lines patch added patch discarded remove patch
@@ -37,7 +37,9 @@  discard block
 block discarded – undo
37 37
 		ini_set("memory_limit", "2048M");
38 38
 		ini_set("max_execution_time", "259200");
39 39
 		ini_set("upload_max_filesize", "200M");
40
-		if ($this->session->userdata('user_login') == FALSE) redirect(base_url() . '/astpp/login');
40
+		if ($this->session->userdata('user_login') == FALSE) {
41
+			redirect(base_url() . '/astpp/login');
42
+		}
41 43
 	}
42 44
 
43 45
 	function termination_rates_list()
@@ -125,24 +127,20 @@  discard block
 block discarded – undo
125 127
 							$data['check_header'] = $check_header;
126 128
 							$data['page_title'] = 'Termination Rates Preview';
127 129
 							$this->session->set_userdata('import_termination_rate_csv', $actual_file_name);
128
-						}
129
-						else
130
+						} else
130 131
 						{
131 132
 							$data['error'] = "File Uploading Fail Please Try Again";
132 133
 						}
133 134
 					}
134
-				}
135
-				else
135
+				} else
136 136
 				{
137 137
 					$data['error'] == "File Uploading Fail Please Try Again";
138 138
 				}
139
-			}
140
-			else
139
+			} else
141 140
 			{
142 141
 				$data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)";
143 142
 			}
144
-		}
145
-		else
143
+		} else
146 144
 		{
147 145
 			$invalid_flag = true;
148 146
 		}
@@ -200,8 +198,7 @@  discard block
 block discarded – undo
200 198
 				{
201 199
 					$invalid_array[$i] = $csv_data;
202 200
 					$invalid_array[$i]['error'] = $str;
203
-				}
204
-				else
201
+				} else
205 202
 				{
206 203
 					$csv_data['trunk_id'] = $trunkID;
207 204
 					$csv_data['pattern'] = "^" . $csv_data['pattern'] . ".*";
@@ -243,8 +240,7 @@  discard block
 block discarded – undo
243 240
 			$data['failure_count'] = count($invalid_array) - 1;
244 241
 			$data['page_title'] = 'Termination Rates Import Error';
245 242
 			$this->load->view('view_import_error', $data);
246
-		}
247
-		else
243
+		} else
248 244
 		{
249 245
 			$this->session->set_flashdata('astpp_errormsg', 'Total ' . count($new_final_arr) . ' Termination rates imported successfully!');
250 246
 			redirect(base_url() . "rates/termination_rates_list/");
@@ -316,24 +312,20 @@  discard block
 block discarded – undo
316 312
 							$data['page_title'] = "Origination Rates Preview";
317 313
 							$data['check_header'] = $check_header;
318 314
 							$this->session->set_userdata('import_origination_rate_csv', $actual_file_name);
319
-						}
320
-						else
315
+						} else
321 316
 						{
322 317
 							$data['error'] = "File Uploading Fail Please Try Again";
323 318
 						}
324 319
 					}
325
-				}
326
-				else
320
+				} else
327 321
 				{
328 322
 					$data['error'] == "File Uploading Fail Please Try Again";
329 323
 				}
330
-			}
331
-			else
324
+			} else
332 325
 			{
333 326
 				$data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)";
334 327
 			}
335
-		}
336
-		else
328
+		} else
337 329
 		{
338 330
 			$invalid_flag = true;
339 331
 		}
@@ -393,8 +385,7 @@  discard block
 block discarded – undo
393 385
 				{
394 386
 					$invalid_array[$i] = $csv_data;
395 387
 					$invalid_array[$i]['error'] = $str;
396
-				}
397
-				else
388
+				} else
398 389
 				{
399 390
 					$csv_data['pricelist_id'] = $pricelistID;
400 391
 					$csv_data['trunk_id'] = $trunkid;
@@ -439,8 +430,7 @@  discard block
 block discarded – undo
439 430
 			$data['failure_count'] = count($invalid_array) - 1;
440 431
 			$data['page_title'] = 'Origination Rates Import Error';
441 432
 			$this->load->view('view_import_error', $data);
442
-		}
443
-		else
433
+		} else
444 434
 		{
445 435
 			$this->session->set_flashdata('astpp_errormsg', 'Total ' . count($new_final_arr) . ' Origination rates imported successfully!');
446 436
 			redirect(base_url() . "rates/origination_rates_list/");
@@ -470,13 +460,11 @@  discard block
 block discarded – undo
470 460
 				$count = count($error_field);
471 461
 				$str.= $count > 1 ? ' are not valid' : ' is not Valid';
472 462
 				return $str;
473
-			}
474
-			else
463
+			} else
475 464
 			{
476 465
 				return false;
477 466
 			}
478
-		}
479
-		else
467
+		} else
480 468
 		{
481 469
 			$str = rtrim($str, ',');
482 470
 			$error_field = explode(',', $str);
@@ -515,8 +503,7 @@  discard block
 block discarded – undo
515 503
 				'id' => $edit_id,
516 504
 				"reseller_id" => $reseller
517 505
 			);
518
-		}
519
-		else
506
+		} else
520 507
 		{
521 508
 			$where = array(
522 509
 				'id' => $edit_id
@@ -536,8 +523,7 @@  discard block
 block discarded – undo
536 523
 			$edit_data['pattern'] = filter_var($edit_data['pattern'], FILTER_SANITIZE_NUMBER_INT);
537 524
 			$data['form'] = $this->form->build_form($this->rates_form->get_origination_rate_form_fields() , $edit_data);
538 525
 			$this->load->view('view_origination_rate_add_edit', $data);
539
-		}
540
-		else
526
+		} else
541 527
 		{
542 528
 			redirect(base_url() . 'rates/origination_rate_list/');
543 529
 		}
@@ -555,8 +541,7 @@  discard block
 block discarded – undo
555 541
 				$data['validation_errors'] = validation_errors();
556 542
 				echo $data['validation_errors'];
557 543
 				exit;
558
-			}
559
-			else
544
+			} else
560 545
 			{
561 546
 				$add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false);
562 547
 				$add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false);
@@ -566,8 +551,7 @@  discard block
 block discarded – undo
566 551
 				));
567 552
 				exit;
568 553
 			}
569
-		}
570
-		else
554
+		} else
571 555
 		{
572 556
 			$data['page_title'] = 'Add Origination Rate';
573 557
 			if ($this->form_validation->run() == FALSE)
@@ -575,8 +559,7 @@  discard block
 block discarded – undo
575 559
 				$data['validation_errors'] = validation_errors();
576 560
 				echo $data['validation_errors'];
577 561
 				exit;
578
-			}
579
-			else
562
+			} else
580 563
 			{
581 564
 				$add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false);
582 565
 				$add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false);
@@ -715,8 +698,7 @@  discard block
 block discarded – undo
715 698
 				$data['validation_errors'] = validation_errors();
716 699
 				echo $data['validation_errors'];
717 700
 				exit;
718
-			}
719
-			else
701
+			} else
720 702
 			{
721 703
 				$add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false);
722 704
 				$add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false);
@@ -726,8 +708,7 @@  discard block
 block discarded – undo
726 708
 				));
727 709
 				exit;
728 710
 			}
729
-		}
730
-		else
711
+		} else
731 712
 		{
732 713
 			$data['page_title'] = 'Add Termination Rate';
733 714
 			if ($this->form_validation->run() == FALSE)
@@ -735,8 +716,7 @@  discard block
 block discarded – undo
735 716
 				$data['validation_errors'] = validation_errors();
736 717
 				echo $data['validation_errors'];
737 718
 				exit;
738
-			}
739
-			else
719
+			} else
740 720
 			{
741 721
 				$add_array['connectcost'] = $this->common_model->add_calculate_currency($add_array['connectcost'], '', '', false, false);
742 722
 				$add_array['cost'] = $this->common_model->add_calculate_currency($add_array['cost'], '', '', false, false);
@@ -783,11 +763,15 @@  discard block
 block discarded – undo
783 763
 		);
784 764
 		$instant_search = $this->session->userdata('left_panel_search_' . $accounttype . '_pattern');
785 765
 		$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);
766
+		if (!empty($like_str)) {
767
+			$this->db->where($like_str);
768
+		}
787 769
 		$count_all = $this->db_model->countQuery("*", "block_patterns", $where);
788 770
 		$paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
789 771
 		$json_data = $paging_data["json_paging"];
790
-		if (!empty($like_str)) $this->db->where($like_str);
772
+		if (!empty($like_str)) {
773
+			$this->db->where($like_str);
774
+		}
791 775
 		$pattern_data = $this->db_model->getSelect("*", "block_patterns", $where, "id", "ASC", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]);
792 776
 		$grid_fields = json_decode($this->rates_form->build_pattern_list_for_customer($accountid, $accounttype));
793 777
 		$json_data['rows'] = $this->form->build_grid($pattern_data, $grid_fields);
@@ -1371,15 +1355,20 @@  discard block
 block discarded – undo
1371 1355
 
1372 1356
 	function csv_to_array($filename = '', $delimiter = ',')
1373 1357
 	{
1374
-		if (!file_exists($filename) || !is_readable($filename)) return FALSE;
1358
+		if (!file_exists($filename) || !is_readable($filename)) {
1359
+			return FALSE;
1360
+		}
1375 1361
 		$header = NULL;
1376 1362
 		$data = array();
1377 1363
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1378 1364
 		{
1379 1365
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1380 1366
 			{
1381
-				if (!$header) $header = $row;
1382
-				else $data[] = array_combine($header, $row);
1367
+				if (!$header) {
1368
+					$header = $row;
1369
+				} else {
1370
+					$data[] = array_combine($header, $row);
1371
+				}
1383 1372
 			}
1384 1373
 
1385 1374
 			fclose($handle);
@@ -1450,25 +1439,21 @@  discard block
 block discarded – undo
1450 1439
 							$data['check_header'] = $check_header;
1451 1440
 							$data['page_title'] = 'Map CSV to Termination Rates';
1452 1441
 							$this->session->set_userdata('import_termination_rate_mapper_csv', $actual_file_name);
1453
-						}
1454
-						else
1442
+						} else
1455 1443
 						{
1456 1444
 							$data['error'] = "File Uploading Fail Please Try Again";
1457 1445
 						}
1458 1446
 					}
1459
-				}
1460
-				else
1447
+				} else
1461 1448
 				{
1462 1449
 					$data['error'] == "File Uploading Fail Please Try Again";
1463 1450
 				}
1464
-			}
1465
-			else
1451
+			} else
1466 1452
 			{
1467 1453
 				$data['error'] = "Invalid file format : Only CSV file allows to import records(Can't import empty file)";
1468 1454
 				$data['error'] = var_dump($_FILES);
1469 1455
 			}
1470
-		}
1471
-		else
1456
+		} else
1472 1457
 		{
1473 1458
 			$invalid_flag = true;
1474 1459
 		}
@@ -1548,8 +1533,7 @@  discard block
 block discarded – undo
1548 1533
 				{
1549 1534
 					$invalid_array[$i] = $csv_data;
1550 1535
 					$invalid_array[$i]['error'] = $str;
1551
-				}
1552
-				else
1536
+				} else
1553 1537
 				{
1554 1538
 					$new_final_arr[$i]['trunk_id'] = $trunkID;
1555 1539
 					$new_final_arr[$i]['pattern'] = "^" . $csv_data['pattern'] . ".*";
@@ -1599,8 +1583,7 @@  discard block
 block discarded – undo
1599 1583
 			$data['failure_count'] = count($invalid_array) - 1;
1600 1584
 			$data['page_title'] = 'Termination Rates Import Error';
1601 1585
 			$this->load->view('view_import_error', $data);
1602
-		}
1603
-		else
1586
+		} else
1604 1587
 		{
1605 1588
 			$this->session->set_flashdata('astpp_errormsg', 'Total ' . count($new_final_arr) . ' Termination rates imported successfully!');
1606 1589
 			redirect(base_url() . "rates/termination_rate_list/");
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
 			list($txt, $ext) = explode(".", $_FILES['termination_rate_import_mapper']['name']);
1419 1419
 			if ($ext == "csv" && $_FILES['termination_rate_import_mapper']['size'] > 0)
1420 1420
 			{
1421
-			    echo "Checkpoint 1";
1421
+				echo "Checkpoint 1";
1422 1422
 				$error = $_FILES['termination_rate_import_mapper']['error'];
1423 1423
 				if ($error == 0)
1424 1424
 				{
@@ -1431,10 +1431,10 @@  discard block
 block discarded – undo
1431 1431
 					// $csv_data = $this->csvreader->parse_file($uploadedFile, $new_final_arr_key, $check_header);
1432 1432
 
1433 1433
 					$csv_data = $this->utf8_converter($this->csvreader->parse_file($uploadedFile, $field_select, $check_header));
1434
-                    echo var_dump($csv_data);
1434
+					echo var_dump($csv_data);
1435 1435
 					if (!empty($csv_data))
1436 1436
 					{
1437
-					    echo "Checkpoint 3";
1437
+						echo "Checkpoint 3";
1438 1438
 						$full_path = $this->config->item('rates-file-path');
1439 1439
 						$actual_file_name = "ASTPP-TERMINATION-RATES-" . date("Y-m-d H:i:s") . "." . $ext;
1440 1440
 						if (move_uploaded_file($uploadedFile, $full_path . $actual_file_name))
@@ -1470,7 +1470,7 @@  discard block
 block discarded – undo
1470 1470
 
1471 1471
 		if ($invalid_flag)
1472 1472
 		{
1473
-		    echo "Checkpoint 4";
1473
+			echo "Checkpoint 4";
1474 1474
 			$str = '';
1475 1475
 			if (!isset($_POST['trunk_id']) || empty($_POST['trunk_id']))
1476 1476
 			{
Please login to merge, or discard this patch.