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/reports.php b/application/controllers/reports.php
index a85c8a1c9..8729b2ed1 100644
--- a/application/controllers/reports.php
+++ b/application/controllers/reports.php
@@ -12,13 +12,13 @@ class Reports extends Secure_area
parent::__construct('reports');
$method_name = $this->uri->segment(2);
$exploder = explode('_', $method_name);
- $submodule_id = $exploder[sizeof($exploder)-1];
+ $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_'.$submodule_id,$employee_id))
+ /* if (sizeof($exploder) > 1 && !$this->Employee->has_permission('reports_'.$matches[1],$employee_id))
{
redirect('no_access/'.$submodule_id);
- }
+ } */
$this->load->helper('report');
}
diff --git a/application/helpers/report_helper.php b/application/helpers/report_helper.php
index 2951d937e..8367f2785 100644
--- a/application/helpers/report_helper.php
+++ b/application/helpers/report_helper.php
@@ -92,14 +92,16 @@ function show_report_if_allowed($allowed_modules, $report_prefix, $report_name,
$lang_line = 'reports_' .$report_name;
$report_label = $CI->lang->line($lang_line);
$permission = empty($permission) ? $report_name : $permission;
- if (!empty($report_label))
+ $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)
{
?>
-
+
db->from('modules');
- $this->db->where('module_id like concat("' . $submodule_id . '", "_%")');
+ $this->db->where('module_id like "' . $submodule_id . '_%"');
+ // has no submodules
$result = $this->db->get();
if ($result->num_rows() > 0)
{
$this->db->from('permissions');
- $this->db->where('permissions.module_id like concat("' . $submodule_id . '", "_%")');
+ $this->db->where('permissions.module_id like "' . $submodule_id . '_%"');
$this->db->where("permissions.person_id",$person_id);
$result = $this->db->get();
return $result->num_rows() > 0;
diff --git a/application/views/employees/form.php b/application/views/employees/form.php
index 90b834eef..1fe92dd05 100644
--- a/application/views/employees/form.php
+++ b/application/views/employees/form.php
@@ -102,6 +102,27 @@ echo form_close();
//validation and submit handling
$(document).ready(function()
{
+ $("ul#permission_list > li > input[name='permissions[]']").each(function()
+ {
+ var $this = $(this);
+ $("ul > li > input", $this.parent()).each(function()
+ {
+ var $that = $(this);
+ var updateCheckboxes = function (checked)
+ {
+ if (checked) {
+ $that.removeAttr("disabled");
+ } else {
+ $that.attr("disabled", "disabled");
+ $that.removeAttr("checked", "");
+ }
+ }
+ $this.change(function() {
+ updateCheckboxes($this.is(":checked"));
+ });
+ });
+ });
+
$('#employee_form').validate({
submitHandler:function(form)
{
@@ -143,7 +164,30 @@ $(document).ready(function()
{
equalTo: "#password"
},
- email: "email"
+ email: "email", "permissions[]" : {
+ required : function(element) {
+ var checked = false;
+ $("ul#permission_list > li > input:checkbox").each(function()
+ {
+ if ($(this).is(":checked")) {
+ var has_children = false;
+ $("ul > li > input:checkbox", $(this).parent()).each(function()
+ {
+ has_children = true;
+ checked |= $(this).is(":checked");
+ console.log("checking.. " + $(this).val() + " required " + checked);
+ });
+ if (has_children && !checked)
+ {
+ return false;
+ }
+ }
+ });
+ console.log("returning " + !checked);
+ return !checked;
+ },
+ minlength: 1
+ }
},
messages:
{
@@ -171,7 +215,8 @@ $(document).ready(function()
{
equalTo: "lang->line('employees_password_must_match'); ?>"
},
- email: "lang->line('common_email_invalid_format'); ?>"
+ email: "lang->line('common_email_invalid_format'); ?>",
+ "permissions[]": "fill in correctly!!"
}
});
});
diff --git a/application/views/reports/graphical.php b/application/views/reports/graphical.php
index 3a89407ee..a54fca8d9 100644
--- a/application/views/reports/graphical.php
+++ b/application/views/reports/graphical.php
@@ -1,10 +1,10 @@
load->view("partial/header");
+var_dump($data_file);
?>
-