From b1c36b790f21643f38fba5469bccf248f3f4f42c Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Wed, 19 Oct 2016 18:47:57 +0100 Subject: [PATCH] Fix to item pic ID 0 issue (#921) Some code clean up too. --- application/controllers/Items.php | 6 +++--- application/helpers/table_helper.php | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/application/controllers/Items.php b/application/controllers/Items.php index f2ab2f9d7..7b0b21ba7 100644 --- a/application/controllers/Items.php +++ b/application/controllers/Items.php @@ -72,8 +72,8 @@ class Items extends Secure_Controller { $this->load->helper('file'); $this->load->library('image_lib'); - $base_path = "uploads/item_pics/" . $pic_id ; - $images = glob ($base_path. "*"); + $base_path = './uploads/item_pics/' . $pic_id; + $images = glob($base_path . '.*'); if(sizeof($images) > 0) { $image_path = $images[0]; @@ -190,7 +190,7 @@ class Items extends Secure_Controller $data['selected_supplier'] = $item_info->supplier_id; $data['logo_exists'] = $item_info->pic_id != ''; - $images = glob("uploads/item_pics/" . $item_info->pic_id . ".*"); + $images = glob('./uploads/item_pics/' . $item_info->pic_id . '.*'); $data['image_path'] = sizeof($images) > 0 ? base_url($images[0]) : ''; $stock_locations = $this->Stock_location->get_undeleted_all()->result_array(); diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php index 340533a84..ce4b7ffac 100644 --- a/application/helpers/table_helper.php +++ b/application/helpers/table_helper.php @@ -248,20 +248,20 @@ function get_items_manage_table_headers() function get_item_data_row($item, $controller) { $CI =& get_instance(); - $item_tax_info=$CI->Item_taxes->get_info($item->item_id); + $item_tax_info = $CI->Item_taxes->get_info($item->item_id); $tax_percents = ''; foreach($item_tax_info as $tax_info) { - $tax_percents.=to_tax_decimals($tax_info['percent']) . '%, '; + $tax_percents .= to_tax_decimals($tax_info['percent']) . '%, '; } // remove ', ' from last item - $tax_percents=substr($tax_percents, 0, -2); - $controller_name=strtolower(get_class($CI)); + $tax_percents = substr($tax_percents, 0, -2); + $controller_name = strtolower(get_class($CI)); $image = ''; - if (!empty($item->pic_id)) + if ($item->pic_id != '') { - $images = glob("uploads/item_pics/" . $item->pic_id . ".*"); + $images = glob('./uploads/item_pics/' . $item->pic_id . '.*'); if (sizeof($images) > 0) { $image .= '';