diff --git a/.gitignore b/.gitignore index 58bf03044..1ce5a940a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ git-svn-diff.py *.swp *.rej *.orig +*~ diff --git a/application/config/config.php b/application/config/config.php index 315d10762..1d098dd89 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -9,7 +9,7 @@ | | */ -$config['application_version'] = '2.3'; +$config['application_version'] = '2.3.1'; /* |-------------------------------------------------------------------------- diff --git a/application/config/constants.php b/application/config/constants.php index 4a879d360..17c81baa6 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -36,6 +36,10 @@ define('FOPEN_READ_WRITE_CREATE', 'a+b'); define('FOPEN_WRITE_CREATE_STRICT', 'xb'); define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b'); +/* + | Precision for calculations performed on decimals + */ +define("PRECISION", 3); /* End of file constants.php */ /* Location: ./application/config/constants.php */ \ No newline at end of file diff --git a/application/controllers/items.php b/application/controllers/items.php index 4526148d6..6b1a71a63 100644 --- a/application/controllers/items.php +++ b/application/controllers/items.php @@ -6,6 +6,7 @@ class Items extends Secure_area implements iData_controller function __construct() { parent::__construct('items'); + $this->load->library('item_lib'); } function index() @@ -16,9 +17,14 @@ class Items extends Secure_area implements iData_controller $config['uri_segment'] = 3; $this->pagination->initialize($config); + $stock_location=$this->item_lib->get_item_location(); + $stock_locations=$this->Stock_locations->get_allowed_locations(); + $data['stock_location']=$this->item_lib->get_item_location(); + $data['stock_locations']=$stock_locations; + $data['controller_name']=strtolower(get_class()); $data['form_width']=$this->get_form_width(); - $data['manage_table']=get_items_manage_table( $this->Item->get_all( $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this ); + $data['manage_table']=get_items_manage_table( $this->Item->get_all( $stock_location, $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this ); $this->load->view('items/manage',$data); } @@ -27,7 +33,13 @@ class Items extends Secure_area implements iData_controller $is_serialized=$this->input->post('is_serialized'); $no_description=$this->input->post('no_description'); $search_custom=$this->input->post('search_custom');//GARRISON ADDED 4/13/2013 - $is_deleted=$this->input->post('is_deleted'); // Parq 131215 + $is_deleted=$this->input->post('is_deleted'); // Parq 131215 + $this->item_lib->set_item_location($this->input->post('stock_location')); + + $stock_location=$this->input->post('stock_location'); + $stock_locations=$this->Stock_locations->get_allowed_locations(); + $data['stock_location']=$this->item_lib->get_item_location(); + $data['stock_locations']=$stock_locations; $data['search_section_state']=$this->input->post('search_section_state'); $data['is_serialized']=$this->input->post('is_serialized'); @@ -36,7 +48,7 @@ class Items extends Secure_area implements iData_controller $data['is_deleted']=$this->input->post('is_deleted'); // Parq 131215 $data['controller_name']=strtolower(get_class()); $data['form_width']=$this->get_form_width(); - $data['manage_table']=get_items_manage_table($this->Item->get_all_filtered($is_serialized,$no_description,$search_custom,$is_deleted),$this);//GARRISON MODIFIED 4/13/2013, Parq 131215 + $data['manage_table']=get_items_manage_table($this->Item->get_all_filtered($stock_location,$is_serialized,$no_description,$search_custom,$is_deleted),$this);//GARRISON MODIFIED 4/13/2013, Parq 131215 $this->load->view('items/manage',$data); } @@ -182,13 +194,15 @@ class Items extends Secure_area implements iData_controller function get_row() { $item_id = $this->input->post('row_id'); - $data_row=get_item_data_row($this->Item->get_info($item_id),$this); + $stock_location_id=$this->item_lib->get_item_location(); + $data_row=get_item_data_row($this->Item->get_info($item_id,$stock_location_id),$this); echo $data_row; } function view($item_id=-1) { - $data['item_info']=$this->Item->get_info($item_id); + $stock_location_id=$this->item_lib->get_item_location(); + $data['item_info']=$this->Item->get_info($item_id,$stock_location_id); $data['item_tax_info']=$this->Item_taxes->get_info($item_id); $suppliers = array('' => $this->lang->line('items_none')); foreach($this->Supplier->get_all()->result_array() as $row) @@ -197,20 +211,19 @@ class Items extends Secure_area implements iData_controller } $data['suppliers']=$suppliers; - $data['selected_supplier'] = $this->Item->get_info($item_id)->supplier_id; + $data['selected_supplier'] = $this->Item->get_info($item_id,$stock_location_id)->supplier_id; $data['default_tax_1_rate']=($item_id==-1) ? $this->Appconfig->get('default_tax_1_rate') : ''; $data['default_tax_2_rate']=($item_id==-1) ? $this->Appconfig->get('default_tax_2_rate') : ''; $locations_data = $this->Stock_locations->get_undeleted_all()->result_array(); - $location_array; foreach($locations_data as $location) { $quantity = $this->Item_quantities->get_item_quantity($item_id, $location['location_id'])->quantity; $quantity = ($item_id == -1) ? null: $quantity; $location_array[$location['location_id']] = array('location_name'=>$location['location_name'], 'quantity'=>$quantity); + $data['stock_locations']= $location_array; } - $data['stock_locations']= $location_array; $this->load->view("items/form",$data); } diff --git a/application/controllers/no_access.php b/application/controllers/no_access.php index cba136e5c..eec4334ed 100644 --- a/application/controllers/no_access.php +++ b/application/controllers/no_access.php @@ -6,7 +6,7 @@ class No_Access extends CI_Controller parent::__construct(); } - function index($module_id='') + function index($module_id='',$submodule_id='') { $data['module_name']=$this->Module->get_module_name($module_id); $this->load->view('no_access',$data); diff --git a/application/controllers/receivings.php b/application/controllers/receivings.php index c620210d7..39de5c527 100644 --- a/application/controllers/receivings.php +++ b/application/controllers/receivings.php @@ -4,7 +4,7 @@ class Receivings extends Secure_area { function __construct() { - parent::__construct('receivings'); + parent::__construct('receivings','items'); $this->load->library('receiving_lib'); } diff --git a/application/controllers/reports.php b/application/controllers/reports.php index 294594f0e..8729b2ed1 100644 --- a/application/controllers/reports.php +++ b/application/controllers/reports.php @@ -6,9 +6,19 @@ define("FORM_WIDTH", "400"); class Reports extends Secure_area { + function __construct() { parent::__construct('reports'); + $method_name = $this->uri->segment(2); + $exploder = explode('_', $method_name); + $submodule_id = preg_match("/([^_.]*)(?:_graph)?$/", $method_name, $matches); + $employee_id=$this->Employee->get_logged_in_employee_info()->person_id; + // check access to report submodule + /* if (sizeof($exploder) > 1 && !$this->Employee->has_permission('reports_'.$matches[1],$employee_id)) + { + redirect('no_access/'.$submodule_id); + } */ $this->load->helper('report'); } @@ -927,7 +937,7 @@ class Reports extends Secure_area } $data = array( - "title" => $this->lang->line('reports_low_inventory_report'), + "title" => $this->lang->line('reports_inventory_low_report'), "subtitle" => '', "headers" => $model->getDataColumns(), "data" => $tabular_data, diff --git a/application/controllers/sales.php b/application/controllers/sales.php index c6eeddb17..f5432f50c 100644 --- a/application/controllers/sales.php +++ b/application/controllers/sales.php @@ -4,7 +4,7 @@ class Sales extends Secure_area { function __construct() { - parent::__construct('sales'); + parent::__construct('sales','items'); $this->load->library('sale_lib'); } @@ -361,17 +361,8 @@ class Sales extends Secure_area $data['modes']=array('sale'=>$this->lang->line('sales_sale'),'return'=>$this->lang->line('sales_return')); $data['mode']=$this->sale_lib->get_mode(); - $data['stock_locations'] = array(); - $stock_locations = $this->Stock_locations->get_undeleted_all()->result_array(); - $show_stock_locations = count($stock_locations) > 1; - if ($show_stock_locations) { - foreach($stock_locations as $location_data) - { - $data['stock_locations'][$location_data['location_id']] = $location_data['location_name']; - } - $data['stock_location']=$this->sale_lib->get_sale_location(); - } - $data['show_stock_locations'] = $show_stock_locations; + $data['stock_locations']=$this->Stock_locations->get_allowed_locations(); + $data['stock_location']=$this->sale_lib->get_sale_location(); $data['subtotal']=$this->sale_lib->get_subtotal(); $data['taxes']=$this->sale_lib->get_taxes(); diff --git a/application/controllers/secure_area.php b/application/controllers/secure_area.php index 5dda41ed0..dbdd750bc 100644 --- a/application/controllers/secure_area.php +++ b/application/controllers/secure_area.php @@ -5,7 +5,7 @@ class Secure_area extends CI_Controller Controllers that are considered secure extend Secure_area, optionally a $module_id can be set to also check if a user can access a particular module in the system. */ - function __construct($module_id=null) + function __construct($module_id=null,$submodule_id=null) { parent::__construct(); $this->load->model('Employee'); @@ -13,8 +13,9 @@ class Secure_area extends CI_Controller { redirect('login'); } - - if(!$this->Employee->has_permission($module_id,$this->Employee->get_logged_in_employee_info()->person_id)) + $submodule_id = empty($submodule_id) ? $module_id : $submodule_id; + $employee_id=$this->Employee->get_logged_in_employee_info()->person_id; + if(!$this->Employee->has_permission($module_id,$employee_id) || !$this->Employee->has_subpermission($submodule_id,$employee_id)) { redirect('no_access/'.$module_id); } diff --git a/application/helpers/report_helper.php b/application/helpers/report_helper.php index 2b380e316..8367f2785 100644 --- a/application/helpers/report_helper.php +++ b/application/helpers/report_helper.php @@ -84,4 +84,26 @@ function random_color() $c .= sprintf("%02X", mt_rand(0, 255)); } return $c; +} + +function show_report_if_allowed($allowed_modules, $report_prefix, $report_name, $permission='') +{ + $CI =& get_instance(); + $lang_line = 'reports_' .$report_name; + $report_label = $CI->lang->line($lang_line); + $permission = empty($permission) ? $report_name : $permission; + $report_prefix = empty($report_prefix) ? '' : $report_prefix . '_'; + // no summary nor detailed reports for receivings + if (!empty($report_label) && !(preg_match('/.*summary_?$/', $report_prefix) && $report_name === "receivings")) + { + foreach($allowed_modules->result() as $module) + { + if ($module->module_id == 'reports_'. $permission) + { + ?> +
'search_form')); ?>
diff --git a/application/views/partial/header.php b/application/views/partial/header.php
index 3f65a343f..9b2514a18 100644
--- a/application/views/partial/header.php
+++ b/application/views/partial/header.php
@@ -44,13 +44,16 @@ html {
result() as $module)
{
- ?>
+ if (sizeof(explode('_', $module->module_id)) == 1)
+ {
+ ?>
-
diff --git a/application/views/reports/graphical.php b/application/views/reports/graphical.php
index 3a89407ee..847f70505 100644
--- a/application/views/reports/graphical.php
+++ b/application/views/reports/graphical.php
@@ -4,7 +4,6 @@ $this->load->view("partial/header");