public function definition() { global $CFG; $mform =& $this->_form; $mform->addElement('hidden', 'shopsettingsid', $this->shopsettingsid); $mform->setType('shopsettingsid', PARAM_INT); $mform->addElement('hidden', 'currency', $this->currency); $mform->setType('currency', PARAM_TEXT); $mform->addElement('hidden', 'deletedBlockPrices', 0); $mform->setType('deletedBlockPrices', PARAM_INT); // Adding the elements in the definition_after_data function rather than in the definition function // so that when the currentcourses or potentialcourses get changed in the process function, the // changes get displayed, rather than the lists as they are before processing. $mform->addElement('header', 'header', get_string('Course', 'block_iomad_commerce')); if (!$this->isadding || count($this->currentcourses->find_courses(''))) { if ($this->isadding) { $mform->addElement('html', "<div class='fitem'><div class='fitemtitle'>" . get_string('selectcoursetoadd', 'block_iomad_commerce') . "</div><div class='felement'>"); $mform->addElement('html', $this->currentcourses->display(true)); $mform->addElement('html', "</div></div>"); } else { $mform->addElement('static', 'coursefullname', get_string('Course', 'block_iomad_commerce'), $this->course->fullname); } $mform->addElement('selectyesno', 'enabled', get_string('course_shop_enabled', 'block_iomad_commerce')); $mform->addHelpButton('enabled', 'course_shop_enabled', 'block_iomad_commerce'); $mform->addElement('editor', 'short_summary_editor', get_string('course_short_summary', 'block_iomad_commerce'), null, $this->editoroptions); $mform->setType('short_summary_editor', PARAM_RAW); $mform->addRule('short_summary_editor', get_string('missingshortsummary', 'block_iomad_commerce'), 'required', null, 'client'); $mform->addElement('editor', 'summary_editor', get_string('course_long_description', 'block_iomad_commerce'), null, $this->editoroptions); $mform->setType('summary_editor', PARAM_RAW); $mform->addElement('header', 'header', get_string('single_purchase', 'block_iomad_commerce')); $mform->addElement('selectyesno', 'allow_single_purchase', get_string('allow_single_purchase', 'block_iomad_commerce')); $mform->addHelpButton('allow_single_purchase', 'allow_single_purchase', 'block_iomad_commerce'); $mform->addElement('text', 'single_purchase_price', get_string('single_purchase_price', 'block_iomad_commerce') . ' ' . $this->currency); $mform->addRule('single_purchase_price', get_string('decimalnumberonly', 'block_iomad_commerce'), 'numeric'); $mform->setType('single_purchase_price', PARAM_TEXT); $mform->addHelpButton('single_purchase_price', 'single_purchase_price', 'block_iomad_commerce'); $mform->addElement('text', 'single_purchase_validlength', get_string('single_purchase_validlength', 'block_iomad_commerce')); $mform->setType('single_purchase_validlength', PARAM_INT); $mform->addHelpButton('single_purchase_validlength', 'single_purchase_validlength', 'block_iomad_commerce'); $mform->addElement('text', 'single_purchase_shelflife', get_string('single_purchase_shelflife', 'block_iomad_commerce')); $mform->setType('single_purchase_shelflife', PARAM_INT); $mform->addHelpButton('single_purchase_shelflife', 'single_purchase_shelflife', 'block_iomad_commerce'); /****** license blocks *********/ $mform->addElement('header', 'header', get_string('licenseblocks', 'block_iomad_commerce')); $mform->addElement('selectyesno', 'allow_license_blocks', get_string('allow_license_blocks', 'block_iomad_commerce')); $mform->addHelpButton('allow_license_blocks', 'allow_license_blocks', 'block_iomad_commerce'); $table = new html_table(); $table->id = "licenseblockstable"; $table->head = array(get_string('licenseblock_start', 'block_iomad_commerce'), get_string('licenseblock_price', 'block_iomad_commerce'), get_string('licenseblock_validlength', 'block_iomad_commerce'), get_string('licenseblock_shelflife', 'block_iomad_commerce'), ""); $table->align = array("left", "left", "left", "left"); $table->width = "95%"; $mform->addElement('static', 'priceblockerrors'); $strdelete = get_string('delete'); $mform->addElement('html', '<span id="deleteText" style="display:none">' . $strdelete . '</span>'); if ($this->priceblocks) { $i = 1; foreach ($this->priceblocks as $priceblock) { $table->data[] = array('<input name="block_start_' . $i . '" type="text" value="' . $priceblock->price_bracket_start . '" size="5" />', $this->currency . '<input name="block_price_' . $i . '" type="text" value="' . $priceblock->price . '" size="5" />', '<input name="block_valid_' . $i . '" type="text" value="' . $priceblock->validlength . '" size="5" />', '<input name="block_shelflife_' . $i . '" type="text" value="' . $priceblock->shelflife . '" size="5" />', '<a href="#" onclick="iomad.removeLicenseBlock(this)">' . $strdelete . '</a>'); $i++; } $mform->addElement('hidden', 'blockPrices', count($this->priceblocks)); $mform->setType('blockPrices', PARAM_INT); } else { $table->data[] = array('<input name="block_start_1" type="text" value="1" size="5" />', $this->currency . '<input name="block_price_1" type="text" value="" size="5" />', '<input name="block_valid_1" type="text" value="" size="5" />', '<input name="block_shelflife_1" type="text" value="" size="5" />', '<a href="#" onclick="iomad.removeLicenseBlock(this)">' . $strdelete . '</a>'); $mform->addElement('hidden', 'blockPrices', 1); $mform->setType('blockPrices', PARAM_INT); } if (!empty($table)) { $mform->addElement('html', "<div class='fitem'><div class='fitemtitle'>" . get_string('licenseblocks', 'block_iomad_commerce') . "</div><div class='felement'>"); $mform->addElement('html', html_writer::table($table)); $mform->addElement('html', "<input type='button' onclick='iomad.addLicenseBlock(this)' value='" . get_string('add_more_license_blocks', 'block_iomad_commerce') . "' />"); $mform->addElement('html', "</div></div>"); global $PAGE; $PAGE->requires->js('/blocks/iomad_commerce/module.js'); } /******** end license blocks *********/ /******** tags **************/ $mform->addElement('header', 'header', get_string('categorization', 'block_iomad_commerce')); $mform->addElement('textarea', 'tags', get_string('tags', 'block_iomad_commerce'), array('rows' => 5, 'cols' => 60)); $mform->addHelpButton('tags', 'tags', 'block_iomad_commerce'); $mform->setType('tags', PARAM_NOTAGS); $vars = get_shop_tags(); $options = "<option value=''>" . get_string('select_tag', 'block_iomad_commerce') . "</option>"; foreach ($vars as $i) { $options .= "<option value='{$i}'>{$i}</option>"; } $select = "<select class='tags' onchange='iomad.onSelectTag(this)'>{$options}</select>"; $html = "<div class='fitem'><div class='fitemtitle'></div><div class='felement'>{$select}</div></div>"; $mform->addElement('html', $html); global $PAGE; $PAGE->requires->js('/blocks/iomad_commerce/module.js'); /******** end tags **********/ $submitlabel = null; // Default. if ($this->isadding) { $submitlabel = get_string('add_course_to_shop', 'block_iomad_commerce'); $mform->addElement('hidden', 'createnew', 1); $mform->setType('createnew', PARAM_INT); } $this->add_action_buttons(true, $submitlabel); } else { $mform->addElement('html', get_string('nocoursesnotontheshop', 'block_iomad_commerce')); } }
} } $tagjoin = ''; $tagwhere = ''; $sqlparams = array(); $tagfilters = ''; if (isset($SESSION->shoptag)) { $tagfilters = "<li>"; $tagfilters .= get_string('filtered_by_tag', 'block_iomad_commerce', '<em>' . $SESSION->shoptag . '</em>'); $tagfilters .= "</li>"; $tagjoin = 'INNER JOIN {course_shoptag} cst ON cst.courseid = c.id INNER JOIN {shoptag} st ON cst.shoptagid = st.id'; $tagwhere = ' AND st.tag = :tag '; $sqlparams['tag'] = $SESSION->shoptag; } else { $shoptags = get_shop_tags(); if (count($shoptags)) { echo get_string('filter_by_tag', 'block_iomad_commerce'); foreach ($shoptags as $shoptag) { echo "<a href='?tag={$shoptag}'>{$shoptag}</a> "; } } } echo "<ul id='filtering'>"; echo $tagfilters; // ...***********search*****************. $searchkey = ''; if (array_key_exists('q', $_GET)) { $searchkey = optional_param('q', '', PARAM_NOTAGS); if ($searchkey) { $SESSION->shopsearch = $searchkey;