// Get the number of companies. $objectcount = $DB->count_records_sql('SELECT COUNT(*) ' . $sql, $sqlparams); echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl); if ($objectcount) { if ($courses = $DB->get_recordset_sql('SELECT c.id AS thecourseid, css.*, c.fullname, sbp.* ' . $sql, $sqlparams, $page, $perpage)) { $strbuynow = get_string('buynow', 'block_iomad_commerce'); $strmoreinfo = get_string('moreinfo', 'block_iomad_commerce'); $table = new html_table(); $table->head = array(get_string('Course', 'block_iomad_commerce'), "", ""); $table->align = array("left", "center", "center"); $table->width = "600px"; foreach ($courses as $course_shopsetting) { $available = $course_shopsetting->allow_single_purchase || $course_shopsetting->allow_license_blocks; if ($available) { $buynowbutton = "<a href=\"course.php?id={$course_shopsetting->thecourseid}#buynow\">{$strbuynow}</a>"; $price = get_lowest_price_text($course_shopsetting); $moreinfobutton = "{$price} <a href='course.php?id={$course_shopsetting->thecourseid}'>{$strmoreinfo}</a>"; } else { $buynowbutton = ""; $moreinfobutton = "<a href='course.php?id={$course_shopsetting->thecourseid}'>{$strmoreinfo}</a>"; } $table->data[] = array("<h3>{$course_shopsetting->fullname}</h3><p>{$course_shopsetting->short_description}</p>", $moreinfobutton, $buynowbutton); } if (!empty($table)) { echo html_writer::table($table); echo $OUTPUT->paging_bar($objectcount, $page, $perpage, $baseurl); } $courses->close(); } } else { echo "<p>" . get_string('nocoursesontheshop', 'block_iomad_commerce') . "</p>";
$table->head = array(get_string('priceoptions', 'block_iomad_commerce'), "", ""); $table->align = array("left", "center", "center"); $table->width = "600px"; if ($course->allow_single_purchase) { $table->data[] = array(get_string('single_purchase', 'block_iomad_commerce'), $course->single_purchase_currency . number_format($course->single_purchase_price, 2), "<a href='buynow.php?courseid={$course->courseid}'>" . get_string('buynow', 'block_iomad_commerce') . "<a>"); } $form = ''; if ($course->allow_license_blocks) { $priceblocks = $DB->get_records('course_shopblockprice', array('courseid' => $course->courseid), 'price_bracket_start'); if (count($priceblocks)) { if (iomad::is_company_admin()) { foreach ($priceblocks as $priceblock) { $table->data[] = array(get_string('licenseblock_n', 'block_iomad_commerce', $priceblock->price_bracket_start), $priceblock->currency . number_format($priceblock->price, 2), ''); } } else { $price = get_lowest_price_text($course); if (!isloggedin()) { $table->data[] = array(get_string('loginforlicenseoptions', 'block_iomad_commerce'), $price, ""); } else { $table->data[] = array(get_string('licenseoptionsavailableforregisteredcompanies', 'block_iomad_commerce'), $price, ""); } } if (isloggedin() && iomad::is_company_admin()) { $msg = ''; if ($licenseformempty) { $msg = "<p class='error'>" . get_string('licenseformempty', 'block_iomad_commerce') . "</p>"; } $form = '<form action="buynow.php?courseid=$course->courseid" method="get"> <input type="hidden" name="courseid" value="' . $courseid . '" /> <input type="hidden" name="licenses" value="1" /> ' . $msg . '