コード例 #1
0
ファイル: lib.php プロジェクト: narasimhaeabyas/tataaiapro
function select_to_agents_course_enrol($checklist,$enrolid=0,$agentcode=NULL,$designation,$state,$agentbranchcode,$agentsupervisor,$city){
     global $DB,$USER;
    
        $sql = "SELECT u.* FROM {user} u JOIN {local_userdata} ud ON u.id =ud.userid WHERE u.username !='guest' 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)){
                if($checklist=='newusers')
                $sql.=' AND ud.userid not in(' . $enrolid_userss . ')';
                else
                $sql.=' AND ud.userid in(' . $enrolid_userss . ')';
            }
        }
       
		 if(!empty($agentcode) && $agentcode !=='null'){
   
            $agentcode= implode("','",$agentcode);
        if($agentcode !=='null' && $agentcode !=='-1'){ 
             $sql.= " AND ud.agentcode IN('{$agentcode}')"; 
         }
        if($agentcode =='-1'){
           $sql.= ''; 
        }  
     }
     
     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($agentsupervisor !==0 && $agentsupervisor !=='null') { 
       //print_object($supervisor);
         $supervisors= implode(",",$agentsupervisor);
         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($state) && $state !=='null') { 
       //echo $sql;
          $states= implode("','",$state);
          //echo "A Zone".$zones;
         if($states !=='null' && $states !=='-1'){
             $sql.= " AND ud.state IN('{$states}')"; 
         }
         if($states =='-1'){
          $stateN=list_statess();
        
          $allstates= implode("','",$stateN);
           $sql.= " AND ud.state IN('{$allstates}')"; 
        }
      
     }
        
      if(!empty($agentbranchcode) && $agentbranchcode !=='null') { 
       //echo $sql;
          $agentbranchcodes= implode("','",$agentbranchcode);
          //echo "A Zone".$zones;
         if($agentbranchcodes !=='null' && $agentbranchcodes !=='-1'){
             $sql.= " AND ud.agentbranchcode IN('{$agentbranchcodes}')"; 
         }
         if($agentbranchcodes =='-1'){
          $sbranchlist=list_agentbranchcodes();
          $allbranches= implode("','",$sbranchlist);
           $sql.= " AND ud.agentbranchcode IN('{$allbranches}')"; 
        }
      
     }
     if(!empty($city) && $city !=='null') { 
       //echo $sql;
          $cities= implode("','",$city);
          //echo "A Zone".$zones;
         if($cities !=='null' && $cities !=='-1'){
             $sql.= " AND u.city IN('{$cities}')"; 
         }
         if($cities =='-1'){
          $citien=list_cities();
        
          $allcities= implode("','",$citien);
           $sql.= " AND u.city IN('{$allcities}')"; 
        }
      
     }
     //echo $sql;
           //$sql.= " GROUP BY ud."; 
        $attendees = $DB->get_records_sql($sql);
        return $attendees;
}
コード例 #2
0
    $fields = array($fullname, 'email', 'idnumber', 'username');
    $keywords = search_parse_keywords($searchtext);
    list($searchwhere, $searchparams) = search_get_keyword_where_clause($keywords, $fields);

    $where .= ' AND ' . $searchwhere;
    $params = array_merge($params, $searchparams);
}

if($designation !=='' && $designation !=='null'){
   
       $designations= implode("','",$designation);
   if($designations !=='null' && $designations !=='all'){ 
       $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}')"; 
   }