</tr>
						</thead>
						<tbody>
						<?php 
            foreach ($ctlg_courses_list as $course_list) {
                $mdl_course = $course_list->getObject();
                $course_list_item = new GcrCourseListItem($course_list);
                $eschool = $course_list->getApp();
                $id = 'gcr_course_' . $eschool->getShortName() . '_' . $mdl_course->id;
                $img_src = $course_list_item->getCourseIconUrl();
                $mdl_user = $course_list_item->getInstructor();
                $summary = $course_list_item->getSummary();
                $enrol_count = $course_list_item->getActiveUserCount();
                $shortsummary = GcrInstitutionTable::formatStringSize($summary, 250, 21);
                if ($mdl_user) {
                    $teacher_text = GcrEschoolTable::getInstructorProfileHtml($mdl_user);
                } else {
                    $teacher_text = 'None';
                }
                $fullname = GcrInstitutionTable::formatStringSize($mdl_course->fullname, 60, 30);
                $cost = $course_list->getCost();
                $cost_text = '';
                //if ($cost) {
                //$cost_text = 'Price: ' . GcrPurchaseTable::gc_format_money($cost);
                $cost_text = GcrPurchaseTable::gc_format_money($cost);
                //}
                $enrollment_status = false;
                $current_user = $CFG->current_app->getCurrentUser();
                if ($current_user->getRoleManager()->hasPrivilege('Student')) {
                    $mdl_roles = $course_list->getRoleAssignments($current_user);
                    $enrollment_status = $mdl_roles && count($mdl_roles > 0);
 public function executeGetHTMLCourseSummary(sfWebRequest $request)
 {
     $return_array = array();
     $eschool_id = $request->getParameter('eschool_id');
     $course_id = $request->getParameter('course_id');
     $eschool = GcrEschoolTable::getEschool($eschool_id);
     $course = $eschool->getCourse($course_id);
     $this->forward404Unless($course);
     $course_collection = $course->getCourseCollection();
     $course_instances = array();
     $courses = array($course);
     $product_short_name = "";
     $course_product_id = $request->getParameter('course_product_id');
     $product_details = GcrProductsTable::getProductDetailsById($course_product_id);
     foreach ($product_details as $product) {
         $product_short_name = $product->getShortName();
     }
     if ($course_collection) {
         if (!$course->isRepresentative()) {
             $course = $course_collection->getRepresentativeCourse();
         }
         $courses = $course_collection->getCourses();
         $category = $course_collection->getCourseCategory();
         $summary = $category->getDescription();
         $summary_edit_url = $category->getApp()->getAppUrl() . '/course/editcategory.php?id=' . $category->getObject()->id;
     }
     $course_obj = $course->getObject();
     if (empty($summary)) {
         $summary = $course->getDescription();
         $summary_edit_url = $course->getApp()->getAppUrl() . '/course/edit.php?id=' . $course->getObject()->id;
     }
     foreach ($courses as $course_instance) {
         $course_instance_array = array();
         $teacher = $course_instance->getInstructor();
         if ($teacher) {
             $course_instance_array['instructor'] = array('id' => $teacher->getObject()->id, 'profile_html' => GcrEschoolTable::getInstructorProfileHtml($teacher), 'app' => $teacher->getApp()->getShortName());
         }
         $cost = $course_instance->getCost();
         $course_instance_array['cost'] = $cost ? $cost : 0;
         $course_instance_array['visible'] = $course_instance->isVisible();
         $course_instance_array['enrolment_count'] = count($course_instance->getActiveUsersInCourse());
         $course_instance_array['admin'] = $this->canAdministerCourse($course_instance);
         $course_instance_array['enrolment_status'] = $this->getEnrolmentStatus($course_instance);
         $course_instance_array['shortname'] = $course_instance->getObject()->shortname;
         $course_instance_array['start_date'] = $course_instance->getObject()->startdate;
         $course_instances[$course_instance->getObject()->id] = $course_instance_array;
     }
     $return_array['eschool_id'] = $course->getApp()->getId();
     $return_array['course_instances'] = $course_instances;
     $return_array['summary'] = $summary;
     $return_array['summary_edit_url'] = $summary_edit_url;
     $return_array['course_fullname'] = $course_obj->fullname;
     $return_array['rep_course_id'] = $course->getObject()->id;
     $return_array['category_id'] = $course_obj->category;
     $return_array['product_short_name'] = $product_short_name;
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     return $this->renderText(json_encode($return_array));
 }