Fix submodules in header

This commit is contained in:
jekkos-t520
2014-09-29 21:06:06 +02:00
parent 13127c4dc7
commit 290533612e
6 changed files with 59 additions and 11 deletions

View File

@@ -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);

View File

@@ -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');
}

View File

@@ -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)
{
?>
<li><a href="<?php echo site_url('reports/' . (empty($report_prefix) ? '' : $report_prefix . '_') . $report_name);?>"><?php echo $report_label; ?></a></li>
<li><a href="<?php echo site_url('reports/' . $report_prefix . $report_name);?>"><?php echo $report_label; ?></a></li>
<?php
}
}

View File

@@ -309,12 +309,13 @@ class Employee extends Person
function has_subpermission($submodule_id,$person_id)
{
$this->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;

View File

@@ -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: "<?php echo $this->lang->line('employees_password_must_match'); ?>"
},
email: "<?php echo $this->lang->line('common_email_invalid_format'); ?>"
email: "<?php echo $this->lang->line('common_email_invalid_format'); ?>",
"permissions[]": "fill in correctly!!"
}
});
});

View File

@@ -1,10 +1,10 @@
<?php
$this->load->view("partial/header");
var_dump($data_file);
?>
<div id="page_title" style="margin-bottom:8px;"><?php echo $title ?></div>
<div id="page_subtitle" style="margin-bottom:8px;"><?php echo $subtitle ?></div>
<div style="text-align: center;">
<script type="text/javascript">
swfobject.embedSWF(
"<?php echo base_url(); ?>open-flash-chart.swf", "chart",