Exemplo n.º 1
0
function select_from_users_course_enrol($enrolid=0,$costcenter=null,$skillset=null,$designation=null,$supervisor=0,$zone=null,$branch=null,$role=0,$category=null,$level=null,$userid=0){
     global $DB,$USER;
     
     if(!is_siteadmin() && $userid!=0){
         $userdepartment=$DB->get_record('local_userdata',array('userid'=>$userid));
        if($userdepartment->lms_category==''){
            $userdepartment_lms_category=0;
            $sql = "SELECT u.* FROM {user} u JOIN {local_userdata} ud ON u.id =ud.userid WHERE u.id >1 AND u.deleted=0 AND u.suspended=0 AND (ud.lms_category!='AST-EXT')"; 
        }else{
            $userdepartment_lms_category=$userdepartment->lms_category;
             $sql = "SELECT u.* FROM {user} u JOIN {local_userdata} ud ON u.id =ud.userid WHERE u.id >1 AND u.deleted=0 AND u.suspended=0 AND (ud.lms_category!='')";
        }
     }elseif(is_siteadmin()){
         $sql = "SELECT u.* FROM {user} u JOIN {local_userdata} ud ON u.id =ud.userid WHERE u.id >1 AND u.deleted=0 AND u.suspended=0 AND (ud.lms_category!='AST-EXT')"; 
     }
        if($enrolid!=0){
             $enrolid_users=$DB->get_fieldset_sql("SELECT userid FROM {user_enrolments} where enrolid=$enrolid");
            array_push($enrolid_users, 1);
            $enrolid_userss = implode(',',$enrolid_users);
            if(!empty($enrolid_userss)){
                $sql .=' AND ud.userid in(' . $enrolid_userss . ')';
            }
        }
        if (!is_siteadmin() && !is_odmanager()) {
       //$costcenterid=$DB->get_record('local_userdata',array('userid'=>$USER->id));
       // $users_list = $DB->get_fieldset_sql('select userid from {local_userdata} where costcenterid='.$costcenterid->costcenterid.'');
       // $useridin = implode(',',$users_list);
       // if(!empty($users_list))
       // $sql .= " AND u.id in ($useridin)";
        
        //$userdepartment=$DB->get_record('local_userdata',array('userid'=>$USER->id));
        // //echo $userdepartment->lms_category;
        // if($userdepartment->lms_category==''){
        //    $userdepartment_lms_category=0;
        //     $users_list = $DB->get_fieldset_sql("SELECT ud.userid FROM {user} u JOIN {local_userdata} ud ON u.id =ud.userid WHERE u.id >1 AND u.deleted=0 AND u.suspended=0 "); 
        //}else{
        //    $userdepartment_lms_category=$userdepartment->lms_category;
        //     $users_list = $DB->get_fieldset_sql("SELECT ud.userid FROM {user} u JOIN {local_userdata} ud ON u.id =ud.userid WHERE u.id >1 AND u.deleted=0 AND u.suspended=0 AND (ud.lms_category!='')");
        //}
        // $useridin = implode(',',$users_list);
        //if(!empty($users_list))
        //$sql.= " AND u.id in($useridin)";
        }
          if(!empty($designation) && $designation !=='null'){
   
            $designations= implode("','",$designation);
        if($designations !=='null' && $designations !=='-1'){ 
             $sql.= " AND ud.designation IN('{$designations}')"; 
         }
        if($designations =='-1'){
          $design=list_departments();
          $alldesignation= implode("','",$design);
           $sql.= " AND ud.designation IN('{$alldesignation}')"; 
        }  
     }
     if(!empty($skillset) && $skillset !=='null'){
          
            $skillsets= implode("','",$skillset);
         if($skillsets !=='null' && $skillsets !=='-1'){
             $sql.= " AND ud.jobfunction IN('{$skillsets}')"; 
         }
         if($skillsets =='-1'){
            
          $skill=list_skillsets();
          //print_object($skill);
          $allskills= implode("','",$skill);
           $sql.= " AND ud.jobfunction IN('{$allskills}')"; 
        }  
     }
     if($costcenter !==0 && $costcenter !=='null') { 
       
         $costcenters= implode("','",$costcenter);
         if($costcenters !==null && $costcenters !=="-1"){
             $sql .= " AND ud.department IN('{$costcenters}')"; 
         }
         if($costcenters =='-1'){
          $centers=get_costcenter_set();
          $allcenters= implode("','",$centers);
           $sql.= " AND ud.department IN('{$allcenters}')"; 
        }  
        
     }
     if(!empty($category) && $category !=='null'){
            
        
        if (in_array("hr", $category)) {
            $array=array();
            foreach($category as $categor){
                if($categor=='hr'){
                   $array[]=""; 
                }else{
                    $array[]=$categor; 
                }
               
            }
          $categorys= implode("','",$array); 
        }else{
            $categorys= implode("','",$category); 
        }
           
         if($categorys !=='null' && $categorys !=='-1'){
             $sql.= " AND ud.lms_category IN('{$categorys}')"; 
         }
         if($categorys =='-1'){
          $skill=get_category_set();
          $allskills= implode("','",$skill);
           $sql.= " AND ud.lms_category IN('{$allskills}')"; 
        }  
     }
     if($supervisor !==0 && $supervisor !=='null') { 
       //print_object($supervisor);
         $supervisors= implode(",",$supervisor);
         if($supervisors !==null && $supervisors !=="-1"){
             $sql .= " AND ud.supervisorid IN({$supervisors})"; 
         }
         if($supervisors =='-1'){
          $centers=list_supervisors();
          $allcenters= implode(",",$centers);
           $sql.= " AND ud.supervisorid IN({$allcenters})"; 
        }  
        
        
     }
     
      if(!empty($zone) && $zone !=='null') { 
       //echo $sql;
          $zones= implode("','",$zone);
         
         if($zones !=='null' && $zones !=='-1'){
             $sql.= " AND ud.zone IN('{$zones}')"; 
         }
         if($zones =='-1'){
          $szone=list_zones();
          $allzones= implode("','",$szone);
           $sql.= " AND ud.zone IN('{$allzones}')"; 
        }  
        
        
     }
    
      if(!empty($branch) && $branch !=='null') { 
       //echo $sql;
          $branches= implode("','",$branch);
          //echo "A Zone".$zones;
         if($branches !=='null' && $branches !=='-1'){
             $sql.= " AND ud.branch IN('{$branches}')"; 
         }
         if($branches =='-1'){
          $sbranch=list_branches();
          $allbranches= implode("','",$sbranch);
           $sql.= " AND ud.branch IN('{$allbranches}')"; 
        }
      
     }
     
      if($role !==0  && $role !=='null') { 
       //echo $sql;
          $roles= implode("','",$role);
         
         if($roles !==0 && $roles !=='-1'){
             $sql.= " AND ud.roleid IN('{$roles}')"; 
         }
         if($roles =='-1'){
          $sroles=list_roles();
          $allroles= implode("','",$sroles);
           $sql.= " AND ud.roleid IN('{$allroles}')"; 
        }
      
     }
     if(!empty($level) && $level !=='null'){
          //print_object($level);
            $levels= implode("','",$level);
         if($levels !=='null' && $levels !=='-1'){
             $sql.= " AND ud.level IN('{$levels}')"; 
         }
         if($levels =='-1'){
          $skill=get_level_set();
          $allskills= implode("','",$skill);
           $sql.= " AND ud.level IN('{$allskills}')"; 
        }  
     }
        $attendees = $DB->get_records_sql($sql);
        return $attendees;
}
Exemplo n.º 2
0
       $where .= " AND ud.designation IN('{$designations}')"; 
    }
   if($designations =='all'){
     $design=list_departments();
     $alldesignation= implode("','",$design);
     $where .= " AND ud.designation IN('{$alldesignation}')"; 
   }  
}
if($skillset !=='' && $skillset !=='null'){
     
       $skillsets= implode("','",$skillset);
    if($skillsets !=='null' && $skillsets !=='all'){
       $where .= " AND ud.skillset IN('{$skillsets}')"; 
    }
    if($skillsets =='all'){
     $skill=list_skillsets();
     $allskills= implode("','",$skill);
     $where .= " AND ud.skillset IN('{$allskills}')"; 
   }  
}


if($subskillset !=='' && $skillset !=='null') {
    $where .= " AND ud.subskillset='{$subskillset}'"; 
    
}

if($costcenter !==0 && $costcenter !=='null') { 
  
    $costcenters= implode(",",$costcenter);
    if($costcenters !==null && $costcenters !=="-1"){