18e04373 by Chris Boden

Course invoices

1 parent e2066462
......@@ -760,12 +760,52 @@ class Actions {
}
public static function wp_ajax_course_registration() {
public static function wp_ajax_course_registration() { // here
$user = new User\Account($_POST['user_id']);
$course = new Courses\Course($_POST['course_id']);
$enrolltype = $_POST['enrolltype'];
$amount = $course->$enrolltype;
$user->registerForCourse($_POST['course_id'], (boolean)isset($_POST['exam']), $_POST['enrolltype']);
$user->approveToCourse($_POST['course_id']);
$items = array();
$items[] = array(
'post_id' => $_POST['course_id']
, 'cost' => $amount
, 'discount_label' => ""
, 'discount_amount' => 0
, 'tax_label' => ""
, 'tax_rate' => ""
, 'tax_amount' => "0.00"
, 'subtotal' => $amount
, 'total' => $amount
, 'description' => $course->post_title
, 'extras' => array()
);
$invoice_data = Array();
$invoice_data['items'] = $items;
$invoice_data['payment'] = array(
'total_cost' => $amount
, 'total_discounts' => ""
, 'total_taxes' => ""
, 'subtotal' => $amount
, 'total' => $amount
, 'bt_address' => ""
, 'bt_address2' => ""
, 'bt_city' => ""
, 'bt_province' => ""
, 'bt_country' => ""
, 'bt_postal' => ""
, 'bt_card_holder' => ""
, 'bt_card_number' => ""
, 'bt_card_type' => $_POST['paid_by']
);
Invoice\create($invoice_data, 'course', 'Course Invoice', $user->ID, 'paid', 'publish', 0);
die(json_encode(Array('success' => 'true', 'refresh' => 'true')));
}
......
......@@ -54,6 +54,19 @@
</div>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">PAID BY</div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
<select name="paid_by">
<option value="visa">Visa</option>
<option value="mc">Mastercard</option>
<option value="amex">American Express</option>
<option value="cheque">Cheque</option>
</select>
</div>
</div>
<div class="dashboard-section" style="margin-left:20px;margin-top:10px;">
<div class="dashboard-section-title">ENROLMENT TYPE</div>
<div class="dashboard-section-links"></div>
<div class="dashboard-section-content small">
......