Location: PHPKode > projects > osSchool > osschool/NewRCSummary_popup.php
<?php
require_once ('config/config.php');
      $session = ossSystem_Session::init();
      $database =  $session->getDatabase();
      $database->DBconnect();
      
      $reportName="";
      $reporPriod="Second";
      $CSV="";
      
      
      $studentGrades = array();
      $studentEfforts = array();
      
      $academicYear=ossSystem_ActionControler::getParam("year");
      $schoolgroup=$session->getCurrentSchoolGroup();
      
      $sesionArray=getSessions($database,$schoolroup,$academicYear);
      $levelArray=getLevels($database,$schoolGroup);
      
      $classArray=getClasses($database,$schoolroup);
      
      $schoollevel='1';
      $academicYear=ossSystem_ActionControler::getParam("year");
      
      ossSystem_Utils::setCSVHeader('rcsummary_' . $reporPriod .'_' . $schoollevel . '.csv');
     
     
      //for each level
      for($levels=0;$level<count($levelArray);$level++){
      	    $studentArray=getStudents($database,$schoolroup,$levelArray[$level]);
        //for each student
            
          //foreach level
            //get Grades
      }
       
      /*
    
     
      //echo $student_query;
      $student_result = $database->DBQuery($student_query);
      while ($student= mysqli_fetch_assoc($student_result)){
          $student_id=$student["student_id"] ;
          $CSV .= QUOTE . $student["last_name"] . ' ' . $student["first_name"] . QUOTE . CR ;
          
          $grade_query="
  SELECT r.reportgrades_id, r.student_id,c.class_name,b.subject_name,a.subjectarea_name,r.grade,r.effort,l.display_text,r.criterion_1,r.criterion_2,r.criterion_3,r.criterion_4,r.criterion_5,r.criterion_6,r.criterion_7,r.criterion_8,r.criterion_9,r.criterion_10
  FROM oss_reportgrades r 
  LEFT JOIN  oss_classyear y ON (y.classyear_id=r.classyear_id) 
  LEFT JOIN  oss_class c ON (c.class_id=y.class_id)  
  LEFT JOIN  oss_subject b  ON (c.subject_id=b.subject_id)  
  LEFT JOIN  oss_subjectarea a  ON (a.subjectarea_id=b.subjectarea_id)    
  LEFT JOIN  oss_lookup l ON ((r.effort=l.display_text_key) AND (lang_key='en'))  
  WHERE ( r.student_id='" . $student_id . "' ) ORDER BY a.sortorder,b.sortorder;";
  
      //echo $grade_query;
      $grade_result = $database->DBQuery($grade_query);

      while ($grade = mysqli_fetch_assoc($grade_result)){
       //  $CSV .= BLANKCELLCOMMA;
         $CSV .= QUOTE . $grade["class_name"] . QUOTECOMMA;
         $CSV .= QUOTE . $grade["subject_name"] . QUOTECOMMA;
         
         $CSV .= QUOTE . $grade["criterion_1"] . QUOTECOMMA;
         $CSV .= QUOTE . $grade["criterion_2"] . QUOTECOMMA;
         $CSV .= QUOTE . $grade["criterion_3"] . QUOTECOMMA;
         $CSV .= QUOTE . $grade["criterion_4"] . QUOTECOMMA;
         $CSV .= QUOTE . $grade["criterion_5"] . QUOTECOMMA;
         $CSV .= QUOTE . $grade["criterion_6"] . QUOTECOMMA;
         $CSV .= QUOTE . $grade["criterion_7"] . QUOTECOMMA;
         $CSV .= QUOTE . $grade["criterion_8"] . QUOTECOMMA;
         $CSV .= QUOTE . $grade["criterion_9"] . QUOTECOMMA;
         $CSV .= QUOTE . $grade["criterion_10"] . QUOTECOMMA;
                           
         
         
         $CSV .= QUOTE . $grade["grade"] . QUOTECOMMA;
         $CSV .= QUOTE . $grade["display_text"] . QUOTE . CR;
       }
       $grade_result->free();
       $CSV .= BLANKLINE;
      }
     $student_result->free();

echo $CSV;

*/

function getStudents($database,$schoolGroup,$level){
	  $studentArray=array();
      $student_query='SELECT student_id,last_name,first_name,schoolLevel 
                      FROM oss_student
                      AND (schoolgroup=\''.$schoolGroup.'\') )
                      ORDER BY last_name,first_name;';
      
       $result = $database->DBQuery($student_query);
      if(!$result) {
      	    echo "Levels Not found";
            $database->DBclose();
            return ;
           }
      $i=0;
      while($row=mysqli_fetch_array($result)){
               $studentArray[$i]['id']=$row['student_id'];
               $studentArray[$i]['nae']=$row['first_name'] . ' '.$row['last_name'] ;
               $i++;
          }  	
      $database->DBfreeResult();
      return $studentArray;
}
       
function getClasses($database,$schoolGroup){      // Get Class lookup
      $classArray=array();
      $class_query='SELECT class_id,class_name ' .
      		       'FROM oss_class ' .
      		       'AND (schoolgroup=\''.$schoolGroup.'\') )';
      
      $result = $database->DBQuery($class_query);
      if(!$result) {
      	    echo "classes Not found";
            $database->DBclose();
            return ;
           }
  
      while($row=mysqli_fetch_array($result)){
               $classArray[$row['class_id']]=$row['class_name'] ;
      }  	
      $database->DBfreeResult(); 
      return $classArray;
}
      
function getSessions   ($database,$schoolGroup,$academicYear){     // Get Sessions 
      $sesionArray=array();    
      $session_query='SELECT reportcardperiod_id,reportcardperiod_name,reportcard_name ' .
      		         'FROM oss_reportcardperiod ' .
      		         'WHERE (academicyear=\''. $academicYear . ')AND($schoolgroup=\''.$schoolGroup.'\')) ' .
      		         'ORDER BY sortorder;'; 
      
      $result = $database->DBQuery($session_query);
      if(!$result) {
      	    echo "Year Not found";
            $database->DBclose();
            return ;
           }
      $i=0;
      while($row=mysqli_fetch_array($result)){
               $sesionArray[$i]['reportcardperiod_id']=$row['reportcardperiod_id'];
               $sesionArray[$i]['reportcardperiod_name']=$row['reportcardperiod_name'];
               $sesionArray[$i]['reportcard_name']=$row['reportcard_name'];
               $i++;
          }  	
      $database->DBfreeResult();   
      return $sesionArray;
}
      
function getLevels ($database,$schoolGroup){    // Get Levels    
      $levelArray=array(); 
      $level_query='SELECT schoollevel ' .
      		       'FROM oss_schoollevel ' .
      		       'WHERE ($schoolgroup=\''.$schoolGroup.'\') ' .
      		       'ORDER BY sortorder;'; 
      
      $result = $database->DBQuery($level_query);
      if(!$result) {
      	    echo "Levels Not found";
            $database->DBclose();
            return ;
           }
      $i=0;
      while($row=mysqli_fetch_array($result)){
               $levelArray[$i]=$row['schoollevel'];
               $i++;
          }  	
      $database->DBfreeResult();    
      return $levelArray;
}
      


?>
Return current item: osSchool