diff --git a/application/controllers/Customers.php b/application/controllers/Customers.php index 7198aac34..d62904a99 100644 --- a/application/controllers/Customers.php +++ b/application/controllers/Customers.php @@ -45,7 +45,7 @@ class Customers extends Persons $stats->quantity = 0; } - $data_row = $this->xss_clean(get_customer_data_row($person, $stats, $this)); + $data_row = $this->xss_clean(get_customer_data_row($person, $stats)); echo json_encode($data_row); } @@ -81,11 +81,9 @@ class Customers extends Persons $stats->quantity = 0; } - $data_rows[] = get_customer_data_row($person, $stats, $this); + $data_rows[] = $this->xss_clean(get_customer_data_row($person, $stats)); } - $data_rows = $this->xss_clean($data_rows); - echo json_encode(array('total' => $total_rows, 'rows' => $data_rows)); } diff --git a/application/controllers/Employees.php b/application/controllers/Employees.php index c3864e288..e3266c53f 100644 --- a/application/controllers/Employees.php +++ b/application/controllers/Employees.php @@ -26,11 +26,9 @@ class Employees extends Persons $data_rows = array(); foreach($employees->result() as $person) { - $data_rows[] = get_person_data_row($person, $this); + $data_rows[] = $this->xss_clean(get_person_data_row($person)); } - $data_rows = $this->xss_clean($data_rows); - echo json_encode(array('total' => $total_rows, 'rows' => $data_rows)); } diff --git a/application/controllers/Giftcards.php b/application/controllers/Giftcards.php index 7a0c607f6..734b7bc4c 100644 --- a/application/controllers/Giftcards.php +++ b/application/controllers/Giftcards.php @@ -33,11 +33,9 @@ class Giftcards extends Secure_Controller $data_rows = array(); foreach($giftcards->result() as $giftcard) { - $data_rows[] = get_giftcard_data_row($giftcard, $this); + $data_rows[] = $this->xss_clean(get_giftcard_data_row($giftcard)); } - $data_rows = $this->xss_clean($data_rows); - echo json_encode(array('total' => $total_rows, 'rows' => $data_rows)); } @@ -61,7 +59,7 @@ class Giftcards extends Secure_Controller public function get_row($row_id) { - $data_row = $this->xss_clean(get_giftcard_data_row($this->Giftcard->get_info($row_id), $this)); + $data_row = $this->xss_clean(get_giftcard_data_row($this->Giftcard->get_info($row_id))); echo json_encode($data_row); } diff --git a/application/controllers/Item_kits.php b/application/controllers/Item_kits.php index 77fde8338..cafa3bb9f 100644 --- a/application/controllers/Item_kits.php +++ b/application/controllers/Item_kits.php @@ -58,11 +58,9 @@ class Item_kits extends Secure_Controller { // calculate the total cost and retail price of the Kit so it can be printed out in the manage table $item_kit = $this->_add_totals_to_item_kit($item_kit); - $data_rows[] = get_item_kit_data_row($item_kit, $this); + $data_rows[] = $this->xss_clean(get_item_kit_data_row($item_kit)); } - $data_rows = $this->xss_clean($data_rows); - echo json_encode(array('total' => $total_rows, 'rows' => $data_rows)); } @@ -78,7 +76,7 @@ class Item_kits extends Secure_Controller // calculate the total cost and retail price of the Kit so it can be added to the table refresh $item_kit = $this->_add_totals_to_item_kit($this->Item_kit->get_info($row_id)); - echo json_encode(get_item_kit_data_row($item_kit, $this)); + echo json_encode(get_item_kit_data_row($item_kit)); } public function view($item_kit_id = -1) diff --git a/application/controllers/Items.php b/application/controllers/Items.php index 24fe93427..c014a5f86 100644 --- a/application/controllers/Items.php +++ b/application/controllers/Items.php @@ -63,7 +63,7 @@ class Items extends Secure_Controller $data_rows = array(); foreach($items->result() as $item) { - $data_rows[] = $this->xss_clean(get_item_data_row($item, $this)); + $data_rows[] = $this->xss_clean(get_item_data_row($item)); if($item->pic_filename!='') { $this->_update_pic_filename($item); @@ -169,7 +169,7 @@ class Items extends Secure_Controller $result = array(); foreach($item_infos->result() as $item_info) { - $result[$item_info->item_id] = $this->xss_clean(get_item_data_row($item_info, $this)); + $result[$item_info->item_id] = $this->xss_clean(get_item_data_row($item_info)); } echo json_encode($result); @@ -478,7 +478,7 @@ class Items extends Secure_Controller echo json_encode(array('success' => FALSE, 'message' => $message, 'id' => $item_id)); } } - else//failure + else // failure { $message = $this->xss_clean($this->lang->line('items_error_adding_updating') . ' ' . $item_data['name']); @@ -750,7 +750,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 = 25; $col < $cols; $col = $col + 2) + for($col = 25; $col < $cols; $col = $col + 2) { $location_id = $data[$col]; if(array_key_exists($location_id, $allowed_locations)) @@ -835,19 +835,20 @@ class Items extends Secure_Controller private function _update_pic_filename($item) { $filename = pathinfo($item->pic_filename, PATHINFO_FILENAME); - if($filename=='') + + // if the field is empty there's nothing to check + if(!empty($filename)) { - // if the field is empty there's nothing to check - return; - } - - $ext = pathinfo($item->pic_filename, PATHINFO_EXTENSION); - if ($ext == '') { - $images = glob('./uploads/item_pics/' . $item->pic_filename . '.*'); - if (sizeof($images) > 0) { - $new_pic_filename = pathinfo($images[0], PATHINFO_BASENAME); - $item_data = array('pic_filename' => $new_pic_filename); - $this->Item->save($item_data, $item->item_id); + $ext = pathinfo($item->pic_filename, PATHINFO_EXTENSION); + if(empty($ext)) + { + $images = glob('./uploads/item_pics/' . $item->pic_filename . '.*'); + if(sizeof($images) > 0) + { + $new_pic_filename = pathinfo($images[0], PATHINFO_BASENAME); + $item_data = array('pic_filename' => $new_pic_filename); + $this->Item->save($item_data, $item->item_id); + } } } } diff --git a/application/controllers/Persons.php b/application/controllers/Persons.php index dca63dbf5..6f6a76f84 100644 --- a/application/controllers/Persons.php +++ b/application/controllers/Persons.php @@ -31,7 +31,7 @@ abstract class Persons extends Secure_Controller */ public function get_row($row_id) { - $data_row = $this->xss_clean(get_person_data_row($this->Person->get_info($row_id), $this)); + $data_row = $this->xss_clean(get_person_data_row($this->Person->get_info($row_id))); echo json_encode($data_row); } diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index 218dc3363..59725ca71 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -57,7 +57,7 @@ class Sales extends Secure_Controller public function get_row($row_id) { $sale_info = $this->Sale->get_info($row_id)->row(); - $data_row = $this->xss_clean(get_sale_data_row($sale_info, $this)); + $data_row = $this->xss_clean(get_sale_data_row($sale_info)); echo json_encode($data_row); } @@ -87,17 +87,17 @@ class Sales extends Secure_Controller $sales = $this->Sale->search($search, $filters, $limit, $offset, $sort, $order); $total_rows = $this->Sale->get_found_rows($search, $filters); $payments = $this->Sale->get_payments_summary($search, $filters); - $payment_summary = $this->xss_clean(get_sales_manage_payments_summary($payments, $sales, $this)); + $payment_summary = $this->xss_clean(get_sales_manage_payments_summary($payments, $sales)); $data_rows = array(); foreach($sales->result() as $sale) { - $data_rows[] = $this->xss_clean(get_sale_data_row($sale, $this)); + $data_rows[] = $this->xss_clean(get_sale_data_row($sale)); } if($total_rows > 0) { - $data_rows[] = $this->xss_clean(get_sale_data_last_row($sales, $this)); + $data_rows[] = $this->xss_clean(get_sale_data_last_row($sales)); } echo json_encode(array('total' => $total_rows, 'rows' => $data_rows, 'payment_summary' => $payment_summary)); diff --git a/application/controllers/Suppliers.php b/application/controllers/Suppliers.php index 02b1d1f71..b07218866 100644 --- a/application/controllers/Suppliers.php +++ b/application/controllers/Suppliers.php @@ -21,7 +21,7 @@ class Suppliers extends Persons */ public function get_row($row_id) { - $data_row = $this->xss_clean(get_supplier_data_row($this->Supplier->get_info($row_id), $this)); + $data_row = $this->xss_clean(get_supplier_data_row($this->Supplier->get_info($row_id))); echo json_encode($data_row); } @@ -43,11 +43,9 @@ class Suppliers extends Persons $data_rows = array(); foreach($suppliers->result() as $supplier) { - $data_rows[] = get_supplier_data_row($supplier, $this); + $data_rows[] = $this->xss_clean(get_supplier_data_row($supplier)); } - $data_rows = $this->xss_clean($data_rows); - echo json_encode(array('total' => $total_rows, 'rows' => $data_rows)); } diff --git a/application/controllers/Taxes.php b/application/controllers/Taxes.php index 022b2c854..89e712aaa 100644 --- a/application/controllers/Taxes.php +++ b/application/controllers/Taxes.php @@ -37,11 +37,9 @@ class Taxes extends Secure_Controller $data_rows = array(); foreach($tax_codes->result() as $tax_code_row) { - $data_rows[] = get_tax_data_row($tax_code_row, $this); + $data_rows[] = $this->xss_clean(get_tax_data_row($tax_code_row)); } - $data_rows = $this->xss_clean($data_rows); - echo json_encode(array('total' => $total_rows, 'rows' => $data_rows)); } @@ -219,4 +217,4 @@ class Taxes extends Secure_Controller } } -?> \ No newline at end of file +?> diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php index 225836a7f..6c3fb417a 100644 --- a/application/helpers/table_helper.php +++ b/application/helpers/table_helper.php @@ -26,7 +26,7 @@ function get_sales_manage_table_headers() /* Gets the html data rows for the sales. */ -function get_sale_data_last_row($sales, $controller) +function get_sale_data_last_row($sales) { $CI =& get_instance(); $sum_amount_due = 0; @@ -49,7 +49,7 @@ function get_sale_data_last_row($sales, $controller) ); } -function get_sale_data_row($sale, $controller) +function get_sale_data_row($sale) { $CI =& get_instance(); $controller_name = $CI->uri->segment(1); @@ -85,7 +85,7 @@ function get_sale_data_row($sale, $controller) /* Get the sales payments summary */ -function get_sales_manage_payments_summary($payments, $sales, $controller) +function get_sales_manage_payments_summary($payments, $sales) { $CI =& get_instance(); $table = '