function definition() { global $CFG; $mform =& $this->_form; $mform->addElement('html', $this->paymentprovider->get_order_review_html()); $mform->addElement('static', 'firstname', get_string('firstname')); $mform->addElement('static', 'lastname', get_string('lastname')); $mform->addElement('static', 'company', get_string('company', 'block_iomad_company_admin')); $mform->addElement('static', 'address', get_string('address')); $mform->addElement('static', 'city', get_string('city')); $mform->addElement('static', 'postcode', get_string('postcode', 'block_iomad_commerce')); $mform->addElement('static', 'country', get_string('country')); $mform->addElement('static', 'email', get_string('email')); $mform->addElement('static', 'phone1', get_string('phone')); $mform->addElement('html', get_basket_html()); $this->add_action_buttons(true, get_string('confirm')); }
} else { $data->company = ""; } $mform = new checkout_form($PAGE->url); $mform->set_data($data); $error = ''; $displaypage = 1; $basketid = get_basket_id(); if ($mform->is_cancelled()) { redirect('basket.php'); } else { if ($data = $mform->get_data()) { $displaypage = 0; $data->id = $basketid; $DB->update_record('invoice', $data, array('id' => $data->id)); $pp = get_payment_provider_instance($data->paymentprovider); $error = $pp->init(); if ($error) { $displaypage = 1; } } } if ($displaypage && !$error) { require_once dirname(__FILE__) . '/processor/processor.php'; processor::trigger_oncheckout($basketid); } $blockpage->display_header(); echo $error; $mform->display(); echo get_basket_html(); echo $OUTPUT->footer();
// Before deleting // check that the record to be removed is on the current user's basket // (and not on an invoice or on somebody else's basket). if ($DB->record_exists_sql('SELECT ii.id FROM {invoiceitem} ii INNER JOIN {course} c ON ii.invoiceableitemid = c.id WHERE ii.id = :toberemoved AND EXISTS ( SELECT id FROM {invoice} i WHERE i.id = :basketid AND i.status = "' . INVOICESTATUS_BASKET . '" AND i.id = ii.invoiceid )', array('basketid' => $SESSION->basketid, 'toberemoved' => $remove))) { $DB->delete_records('invoiceitem', array('id' => $remove)); } } $baskethtml = get_basket_html(1); if ($baskethtml) { echo $baskethtml; echo '<p><a href="checkout.php">' . get_string('checkout', 'block_iomad_commerce') . '</a></p> <p>' . get_string('or', 'block_iomad_commerce') . '</p> <p><a href="shop.php">' . get_string('returntoshop', 'block_iomad_commerce') . '</a></p> '; foreach (get_enabled_payment_providers_instances() as $pp) { echo $pp->get_basketpage_html(); } } else { echo '<p>' . get_string('emptybasket', 'block_iomad_commerce') . '</p>'; } } else { echo '<p>' . get_string('emptybasket', 'block_iomad_commerce') . '</p>'; } echo $OUTPUT->footer();