如何根据月

时间:2016-09-27 07:36:55

标签: php

我需要帮助我尝试了一切,但没有任何作用

以下是我使用权限的代码,如果管理员为team_lead(4)分配权限以填充id = 2用户的 1月月的一般部分,那么它正常工作但是,如果管理员再次向team_lead(4)分配权限,以填充id = 2的用户的三月月的管理部分,那么在user_id的两个月中,它同时显示部分而不是必须在一月三月的管理部分中显示一般部分,请为我提供解决方案。

控制器代码

 $user_id= $this->data['user_id'] = $this->_user['user_id'];
       $q ="select distinct assigned_for , employee.month from section_permissions 
            join employee on (employee.user_id = section_permissions.assigned_for) 
            where section_permissions.user_id = '$user_id' and employee.emp_id =".$emp_id;
      $assigns = $this->section_permission_model->q_single($q); 

       $q = " select group_concat(distinct section_id) as allowed_sections ,section_permissions.user_id from section_permissions join employee on 
        (employee.user_id = section_permissions.assigned_for) where section_id != 0  and section_permissions.user_id = '$user_id' and section_permissions.assigned_for =".$assigns['assigned_for'];
        $row = $this->section_permission_model->q_single($q);
       $allowed = ($row['allowed_sections'])?explode(',',$row['allowed_sections']):array();

        $q = " select distinct section_id, section_permissions.user_id from section_permissions join employee on 
        (employee.user_id = section_permissions.assigned_for) where section_id != 0 and  section_permissions.user_id = '$user_id'  and section_permissions.assigned_for = ".$assigns['assigned_for'];
        $sections = $this->data['sections'] = $this->section_permission_model->q($q);

在视图中我使用:

<?php foreach($sections as $section){ ?>
    <?php foreach($employees as $employee){?>


    <?php if($section['section_id']== 1 && in_array($section['section_id'],$allowed)){?>
<?}?>   
<?}?>   
<?}?>

至于我使用section_id == 2,3的每个部分; 请给我解决方案。

Array
(
    [0] => Array
        (
            [section_id] => 1
            [user_id] => 3
        )

    [1] => Array
        (
            [section_id] => 3
            [user_id] => 3
        )

)

员工数组

Array
(
    [0] => Array
        (
            [emp_id] => 11
            [user_id] => 5
            [month] => May
            [year] => 2016
            [punt] => 5 
            [rel] => 5
            [attend] => 5
            [comm] => 5
            [technical] => 
            [dedication] => 
            [deadline] => 
            [team] => 
            [prof] => 
            [org] => 
            [accu] => 
            [respons] => 
            [ability] => 
            [team_work] => 
            [attempt] => 
            [indep] => 
            [speed] => 
            [accur] => 
            [engage] => 

            [total] => 20
            [mgmt_total] => 
            [prof_total] => 
            [know_total] => 
            [per_total] => 
            [grand_total] => 
            [gen_cmmt] => 
            [mgmt_cmmt] => 
            [prof_cmmt] => 
            [know_cmmt] => 
            [pers_cmmt] => 

        )

)

0 个答案:

没有答案