mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-11 09:14:27 -04:00
Small code refactoring
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -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 = '<div id="report_summary">';
|
||||
@@ -174,7 +174,7 @@ function get_people_manage_table_headers()
|
||||
return transform_headers($headers);
|
||||
}
|
||||
|
||||
function get_person_data_row($person, $controller)
|
||||
function get_person_data_row($person)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$controller_name = strtolower(get_class($CI));
|
||||
@@ -213,7 +213,7 @@ function get_customer_manage_table_headers()
|
||||
return transform_headers($headers);
|
||||
}
|
||||
|
||||
function get_customer_data_row($person, $stats, $controller)
|
||||
function get_customer_data_row($person, $stats)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$controller_name = strtolower(get_class($CI));
|
||||
@@ -254,7 +254,7 @@ function get_suppliers_manage_table_headers()
|
||||
return transform_headers($headers);
|
||||
}
|
||||
|
||||
function get_supplier_data_row($supplier, $controller)
|
||||
function get_supplier_data_row($supplier)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$controller_name = strtolower(get_class($CI));
|
||||
@@ -296,7 +296,7 @@ function get_items_manage_table_headers()
|
||||
return transform_headers($headers);
|
||||
}
|
||||
|
||||
function get_item_data_row($item, $controller)
|
||||
function get_item_data_row($item)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$item_tax_info = $CI->Item_taxes->get_info($item->item_id);
|
||||
@@ -384,7 +384,7 @@ function get_taxes_manage_table_headers()
|
||||
return transform_headers($headers);
|
||||
}
|
||||
|
||||
function get_giftcard_data_row($giftcard, $controller)
|
||||
function get_giftcard_data_row($giftcard)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$controller_name=strtolower(get_class($CI));
|
||||
@@ -400,7 +400,7 @@ function get_giftcard_data_row($giftcard, $controller)
|
||||
));
|
||||
}
|
||||
|
||||
function get_tax_data_row($tax_code_row, $controller)
|
||||
function get_tax_data_row($tax_code_row)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$controller_name=strtolower(get_class($CI));
|
||||
@@ -435,7 +435,7 @@ function get_item_kits_manage_table_headers()
|
||||
return transform_headers($headers);
|
||||
}
|
||||
|
||||
function get_item_kit_data_row($item_kit, $controller)
|
||||
function get_item_kit_data_row($item_kit)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$controller_name = strtolower(get_class($CI));
|
||||
|
||||
@@ -580,7 +580,7 @@ class Item extends CI_Model
|
||||
//only return $limit suggestions
|
||||
if(count($suggestions > $limit))
|
||||
{
|
||||
$suggestions = array_slice($suggestions, 0,$limit);
|
||||
$suggestions = array_slice($suggestions, 0, $limit);
|
||||
}
|
||||
|
||||
return $suggestions;
|
||||
@@ -691,7 +691,7 @@ class Item extends CI_Model
|
||||
//only return $limit suggestions
|
||||
if(count($suggestions > $limit))
|
||||
{
|
||||
$suggestions = array_slice($suggestions, 0,$limit);
|
||||
$suggestions = array_slice($suggestions, 0, $limit);
|
||||
}
|
||||
|
||||
return $suggestions;
|
||||
@@ -791,7 +791,7 @@ class Item extends CI_Model
|
||||
//only return $limit suggestions
|
||||
if(count($suggestions > $limit))
|
||||
{
|
||||
$suggestions = array_slice($suggestions, 0,$limit);
|
||||
$suggestions = array_slice($suggestions, 0, $limit);
|
||||
}
|
||||
|
||||
return $suggestions;
|
||||
|
||||
@@ -71,7 +71,7 @@ class Item_kit extends CI_Model
|
||||
pic_filename,
|
||||
allow_alt_description,
|
||||
is_serialized,
|
||||
deleted,
|
||||
items.deleted,
|
||||
custom1,
|
||||
custom2,
|
||||
custom3,
|
||||
|
||||
@@ -895,7 +895,7 @@ class Sale extends CI_Model
|
||||
public function get_sale_items_ordered($sale_id)
|
||||
{
|
||||
$this->db->select('
|
||||
sale_id,
|
||||
sales_items.sale_id,
|
||||
sales_items.item_id,
|
||||
sales_items.description,
|
||||
serialnumber,
|
||||
@@ -912,7 +912,7 @@ class Sale extends CI_Model
|
||||
stock_type');
|
||||
$this->db->from('sales_items as sales_items');
|
||||
$this->db->join('items as items', 'sales_items.item_id = items.item_id');
|
||||
$this->db->where('sale_id', $sale_id);
|
||||
$this->db->where('sales_items.sale_id', $sale_id);
|
||||
|
||||
// Entry sequence (this will render kits in the expected sequence)
|
||||
if($this->config->item('line_sequence') == '0')
|
||||
|
||||
@@ -124,16 +124,13 @@
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<?php foreach($allowed_modules as $module): ?>
|
||||
<li class="<?php echo $module->module_id == $this->uri->segment(1) ? 'active' : ''; ?>">
|
||||
<a href="<?php echo site_url("$module->module_id"); ?>"
|
||||
title="<?php echo $this->lang->line("module_" . $module->module_id); ?>"
|
||||
class="menu-icon">
|
||||
<img src="<?php echo base_url() . 'images/menubar/' . $module->module_id . '.png'; ?>"
|
||||
border="0" alt="Module Icon"/><br/>
|
||||
<li class="<?php echo $module->module_id == $this->uri->segment(1) ? 'active' : ''; ?>">
|
||||
<a href="<?php echo site_url("$module->module_id"); ?>" title="<?php echo $this->lang->line("module_" . $module->module_id); ?>" class="menu-icon">
|
||||
<img src="<?php echo base_url() . 'images/menubar/' . $module->module_id . '.png'; ?>" border="0" alt="Module Icon"/><br/>
|
||||
<?php echo $this->lang->line("module_" . $module->module_id) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user