public function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $strrequired = get_string('required');
     $mform->addElement('hidden', 'id', $this->invoiceid);
     $mform->addElement('header', 'header', get_string('order', 'block_iomad_commerce'));
     $mform->addElement('static', 'reference', get_string('reference', 'block_iomad_commerce'));
     $choices = array();
     foreach (array(INVOICESTATUS_UNPAID, INVOICESTATUS_PAID) as $status) {
         $choices[$status] = get_string('status_' . $status, 'block_iomad_commerce');
     }
     $mform->addElement('select', 'status', get_string('status', 'block_iomad_commerce'), $choices);
     $mform->addRule('status', $strrequired, 'required', null, 'client');
     $mform->addElement('header', 'header', get_string('purchaser_details', 'block_iomad_commerce'));
     $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('selectacountry'));
     $mform->addElement('static', 'email', get_string('email'));
     $mform->addElement('static', 'phone1', get_string('phone'));
     $mform->addElement('header', 'header', get_string('basket', 'block_iomad_commerce'));
     $mform->addElement('html', '<p>' . get_string('process_help', 'block_iomad_commerce') . '</p>');
     $mform->addElement('html', get_invoice_html($this->invoiceid, 0, 0, 1));
     $mform->addElement('header', 'header', get_string('paymentprocessing', 'block_iomad_commerce'));
     $mform->addElement('static', 'checkout_method', get_string('paymentprovider', 'block_iomad_commerce'));
     foreach (array('pp_payerid', 'pp_ordertime', 'pp_payerstatus', 'pp_transactionid', 'pp_ack', 'pp_transactiontype', 'pp_paymenttype', 'pp_currencycode', 'pp_amount', 'pp_feeamt', 'pp_settleamt', 'pp_taxamt', 'pp_exchangerrate', 'pp_paymentstatus', 'pp_pendingreason', 'pp_reason') as $ppfield) {
         $mform->addElement('static', $ppfield, get_string($ppfield, 'block_iomad_commerce'));
     }
     $this->add_action_buttons();
 }
Esempio n. 2
0
 public function confirm()
 {
     global $DB, $CFG;
     if ($basketid = get_basket_id()) {
         // Send invoice email to the user.
         $basket = get_basket();
         $basket->itemized = get_invoice_html($basketid, 0, 0);
         // Notify shop admin.
         if (isset($CFG->commerce_admin_email)) {
             if (!($shopadmin = $DB->get_record('user', array('email' => $CFG->commerce_admin_email)))) {
                 $shopadmin = new stdClass();
                 $shopadmin->email = $CFG->commerce_admin_email;
                 if (empty($CFG->commerce_admin_firstname)) {
                     $shopadmin->firstname = "Shop";
                 } else {
                     $shopadmin->firstname = $CFG->commerce_admin_firstname;
                 }
                 if (empty($CFG->commerce_admin_lastname)) {
                     $shopadmin->lastname = "Admin";
                 } else {
                     $shopadmin->lastname = $CFG->commerce_admin_lastname;
                 }
                 $shopadmin->id = -999;
             }
         } else {
             $shopadmin = new stdClass();
             $shopadmin->email = $CFG->support_email;
             if (empty($CFG->commerce_admin_firstname)) {
                 $shopadmin->firstname = "Shop";
             } else {
                 $shopadmin->firstname = $CFG->commerce_admin_firstname;
             }
             if (empty($CFG->commerce_admin_lastname)) {
                 $shopadmin->lastname = "Admin";
             } else {
                 $shopadmin->lastname = $CFG->commerce_admin_lastname;
             }
             $shopadmin->id = -999;
         }
         if ($user = $DB->get_record('user', array('id' => $basket->userid))) {
             EmailTemplate::send('invoice_ordercomplete', array('user' => $user, 'invoice' => $basket, 'sender' => $shopadmin));
             // Notify shop admin.
             if (isset($CFG->commerce_admin_email)) {
                 EmailTemplate::send('invoice_ordercomplete_admin', array('user' => $shopadmin, 'invoice' => $basket, 'sender' => $shopadmin));
             }
             // Set status of invoice to unpaid.
             $DB->set_field('invoice', 'status', INVOICESTATUS_UNPAID, array('id' => $basketid));
             return '';
         }
     }
     return '<p class="error">' . get_string('pp_invoice_basketnolongeravailable', 'block_iomad_commerce') . '</p>';
 }
Esempio n. 3
0
function get_basket_html($includeremove = 0)
{
    if ($basketid = get_basket_id()) {
        return get_invoice_html($basketid, $includeremove);
    }
}
Esempio n. 4
0
$linktext = get_string('course_shop_title', 'block_iomad_commerce');
// Set the url.
$linkurl = new moodle_url('/blocks/iomad_commerce/shop.php');
// Build the nav bar.
$PAGE->navbar->add($linktext, $linkurl);
$PAGE->navbar->add(get_string('confirmation', 'block_iomad_commerce'));
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_commerce', 'block', 'confirmation');
$blockpage->setup();
require_login(null, false);
// Adds to $PAGE, creates $OUTPUT.
$context = $PAGE->context;
$blockpage->display_header();
$invoice = get_invoice_by_reference($invoicereference);
$pp = get_payment_provider_instance($invoice->checkout_method);
echo $pp->get_confirmation_html($invoice);
echo get_invoice_html($invoice->id);
// Check if the user has a company.
if (empty($USER->profile['company'])) {
    if (!($company = $DB->get_record('company', array('name' => $invoice->company)))) {
        $company = new object();
        $company->name = $invoice->company;
        $company->shortname = preg_replace('~\\b(\\w)|.~', '$1', $company->name);
        // Does this shortname already exist?
        if ($count = $DB->get_record_sql("SELECT count(id) AS count\n                                          FROM {company}\n                                          WHERE shortname LIKE '" . $company->shortname . "%'")) {
            $count++;
            $company->shortname = $company->shortname . $count->count;
        }
        $company->country = $invoice->country;
        $company->city = $invoice->city;
        $companyid = $DB->insert_record('company', $company);
        // Set up default department.