<?php
/*
*/
   include_once("_nemo.basic.cls.php");


   $page = new NemoBasic();
//print_rr($_SESSION);

   if($Action == "Print Schedule")
   {

      $row = $xdb->getRowSQL("SELECT * FROM tblCourse WHERE CourseID = ". $xdb->qs($CID));

      header("Content-type: application/ms-excel");
      header("Content-Disposition: attachment; filename=KM_". str_replace(" ","", $row->strCourse) ."_". str_replace("/","_", $row->strCourseCode) ."_".date("Y-m-d").".xls");
      echo $page->getCourseSchedule($CID);
      die;
   }

   $rstCourses = $xdb->doQuery("
      SELECT tblCourse.CourseID, tblCourse.refCourseTypeID, tblCourse.strCourse, tblCourse.strCourseHTML, tblCourse.strCourseCode, tblCourse.dblCost, tblCourse.dtStartDate, tblCourse.dtEndDate, tblCourse.blnActive, tblCourse.strLastUser, tblCourse.dtLastEdit, tblLicence.refLearnerID, tblLicence.strStatus, Sum(modAssignment.intMarks) AS SumOfintMarks
      FROM modAssignment RIGHT JOIN (modModule RIGHT JOIN (tblLicence INNER JOIN tblCourse ON tblLicence.refCourseID = tblCourse.CourseID) ON modModule.refCourseID = tblCourse.CourseID) ON modAssignment.refModuleID = modModule.ModuleID
      WHERE tblCourse.blnWorkshop = 0
      GROUP BY tblCourse.CourseID, tblCourse.refCourseTypeID, tblCourse.strCourse, tblCourse.strCourseHTML, tblCourse.strCourseCode, tblCourse.dblCost, tblCourse.dtStartDate, tblCourse.dtEndDate, tblCourse.blnActive, tblCourse.strLastUser, tblCourse.dtLastEdit, tblLicence.refLearnerID, tblLicence.strStatus
      HAVING (((tblCourse.dtEndDate)>=LEFT('$DT',10)) AND ((tblLicence.refLearnerID)=". $page->Learner->LearnerID .") AND ((tblLicence.strStatus)='Active'))
      ", 0);

   while($rowCourse = $xdb->fetch_object($rstCourses))
   {
      $row = $xdb->getRowSQL("SELECT COUNT(refLearnerID) as intLearners FROM (SELECT DISTINCT refLearnerID FROM tblLicence WHERE refCourseID = $rowCourse->CourseID AND strStatus='Active') as tblDir");

      $strCourses .= "
      <h2 class='textColour'>$rowCourse->strCourse</h2>
      <p>Welcome and congratulations. You are one of $row->intLearners people who have signed up for this course. We sincerely believe that this is going to make a difference in your working life.</p>";
      //print_rr($rowCourse);
      if(($rowCourse->refCourseTypeID != 8) && ($rowCourse->refCourseTypeID != 9) && ($rowCourse->refCourseTypeID != 10))
      {
         $strCourses .= "
      <p>Your course program is as follows: <span class='fr'>To print your Course program, <a href='?Action=Print Schedule&CID=$rowCourse->CourseID'>click here</a>.</span></p>".$page->getCourseSchedule($rowCourse->CourseID);
      }

      $strCourses .= "".$page->getCourseCoordinators($rowCourse->CourseID);

   }//eoCourses

   $page->Content = "<h1>Online learning courses</h1>";
   $page->Content .= getTypoIframe($id="hidden/courses/");
   //$page->Content .= $strCourses;


   /*
   <h2 class='textColour'>Technical requirements</h2>
   <p>
      In order to access the course material you will need to have Adobe Acrobat Reader installed on your computer. If you do not have this program or would like an updated version thereof, <a href='http://get.adobe.com/reader/' target=_blank >click here</a>.$BR$BR
      Certain module contains a brief video clip. In order to view this material you will need to have Windows Media Player or a similar program installed on your computer. If you do not have such a program, please refer to your IT support technician for assistance.
   </p>

   <h2 class='textColour'>Adhere to your company requirements</h2>
   <p>
   The notes, material and templates provided by <b>Know</b><b class='textColour'>More</b> are based on industry best principles and are carefully researched. However, there may be very valid reasons for doing things differently in your business. This is often the case when it comes to technology.
   Before implementing new ideas and suggestions, always check your company’s business guidelines and IT policies before you proceed.
   </p>*/

   $page->Display();

?>
