Small code optimisation: review for loops (#709)

This commit is contained in:
FrancescoUK
2016-07-01 19:12:48 +01:00
parent 4d6a665e04
commit d8beedf1f7
3 changed files with 8 additions and 6 deletions

View File

@@ -367,7 +367,8 @@ class Items extends Secure_Controller
$items_taxes_data = array();
$tax_names = $this->input->post('tax_names');
$tax_percents = $this->input->post('tax_percents');
for($k = 0; $k < count($tax_percents); ++$k)
$count = count($tax_percents);
for ($k = 0; $k < $count; ++$k)
{
if(is_numeric($tax_percents[$k]))
{
@@ -520,8 +521,8 @@ class Items extends Secure_Controller
$tax_names = $this->input->post('tax_names');
$tax_percents = $this->input->post('tax_percents');
$tax_updated = FALSE;
for($k = 0; $k < count($tax_percents); ++$k)
$count = count($tax_percents);
for ($k = 0; $k < $count; ++$k)
{
if(!empty($tax_names[$k]) && is_numeric($tax_percents[$k]))
{
@@ -658,7 +659,7 @@ class Items extends Secure_Controller
// array to store information if location got a quantity
$allowed_locations = $this->Stock_location->get_allowed_locations();
for($col = 24; $col < $cols; $col = $col + 2)
for ($col = 24; $col < $cols; $col = $col + 2)
{
$location_id = $data[$col];
if(array_key_exists($location_id, $allowed_locations))

View File

@@ -740,7 +740,7 @@ class Reports extends Secure_Controller
$data['specific_input_name'] = $this->lang->line('reports_discount');
$discounts = array();
for($i = 0; $i <= 100; $i += 10)
for ($i = 0; $i <= 100; $i += 10)
{
$discounts[$i] = $i . '%';
}

View File

@@ -752,7 +752,8 @@ class Sales extends Secure_Controller
// go through all the payment type input from the form, make sure the form matches the name and iterator number
$payments = array();
for($i = 0; $i < $this->input->post('number_of_payments'); ++$i)
$number_of_payments = $this->input->post('number_of_payments');
for ($i = 0; $i < $number_of_payments; ++$i)
{
$payment_amount = $this->input->post('payment_amount_' . $i);
$payment_type = $this->input->post('payment_type_' . $i);