/**
  * this function executes purchase details in screen
  */
 public function emailReceipt()
 {
     $user = $this->my_purchase->getPurchaserUser();
     $institution = $user->getApp();
     $trial_length = 0;
     $type_id_arr = explode("~", $this->my_purchase->getPurchaseTypeId());
     $product_details = GcrProductsTable::getProductDetails($type_id_arr[0], $type_id_arr[1], $this->my_purchase->getPurchaseTypeEschoolId());
     foreach ($product_details as $product) {
         $trial_length = $product->getExpiryNoOfDays();
     }
     $trial_end_date = date('F j, Y', $trial_length * self::DAY + time());
     $params = array('institution_full_name' => $institution->getFullName(), 'institution_short_name' => $institution->getShortName(), 'trial_end_date' => $trial_end_date, 'amountCharged' => number_format($this->amount, 2), 'trial_length' => $trial_length, 'cycle_text' => strtolower($this->my_purchase->getBillCycle()) . 'ly');
     $email = new GcrUserEmailer('purchase_subscription', $user, "Thank you for purchasing a Subscription from " . $institution->getFullName() . "!", $params);
     $email->sendHtmlEmail();
 }
 public function getProductName()
 {
     $type = $this->my_purchase->getPurchaseType();
     if ($type == 'course') {
         return $this->my_product->fullname . ' (' . $this->my_product->shortname . ')';
     }
     if ($type == 'subscription') {
         $product_name = "Subscription";
         $product_details = GcrProductsTable::getProductDetails($this->my_purchase->getPurchaseTypeId(), $this->my_purchase->getProductTypeId(), $this->my_purchase->getPurchaseTypeEschoolId(), $this->my_purchase->getProductShortName());
         foreach ($product_details as $product) {
             $product_name = $product->getFullName();
         }
         //return $this->my_purchase->getPurchaseDescription();
         return $product_name;
     }
     if ($type == 'sale') {
         return 'Graduate Credit';
     } else {
         if ($this->my_purchase->isRecurring()) {
             return $this->my_purchase->getBillCycle() . 'ly Recurring ' . $this->my_purchase->getPurchaseString() . ' Subscription';
         }
     }
 }
Exemplo n.º 3
0
 private function hydratePurchaseObject($object, $type, $type_id, $app_id, $bill_cycle = null)
 {
     // one case for each purchase type
     $this->purchaseObject->eschool = $app_id;
     if (!($app = GcrInstitutionTable::getApp($app_id))) {
         global $CFG;
         $CFG->current_app->gcError('Schema ' . $app_id . ' does not exist.', 'gcdatabaseerror');
     }
     if ($type == 'course') {
         if ($course = $app->getCourse($type_id)) {
             $mdl_course = $course->getObject();
             if ($mdl_enrol = $course->getMdlEnrol()) {
                 $this->purchaseObject->description = 'Course: ' . $mdl_course->fullname . ' (' . $mdl_course->shortname . ')';
                 if ($mdl_enrol->cost > 0) {
                     $this->purchaseObject->cost = $mdl_enrol->cost;
                 } else {
                     if ($enrolCost = $app->getConfigVar('enrol_cost')) {
                         $this->purchaseObject->cost = $enrolCost;
                     }
                 }
             }
         }
     } else {
         if ($type == 'eschool') {
             $this->purchaseObject->description = 'eSchool Activation: ' . $app->getFullName() . ' (' . $app->getShortName() . ')';
             if ($cost = $app->getConfigVar('gc_eschool_cost_' . strtolower($bill_cycle))) {
                 $this->purchaseObject->cost = $cost;
                 $this->purchaseObject->bill_cycle = $bill_cycle . 'ly Subscription';
             }
         } else {
             if ($type == 'classroom' || $type == 'classroom_membership') {
                 $this->purchaseObject->description = 'eClassroom';
                 $this->purchaseObject->description .= $type == 'membership' ? ' Membership ' : '';
                 $this->purchaseObject->description .= ' on ' . $app->getFullName();
                 if ($cost = $app->getConfigVar('gc_classroom_cost_' . strtolower($bill_cycle))) {
                     $this->purchaseObject->cost = $cost;
                     $this->purchaseObject->bill_cycle = $bill_cycle . 'ly Subscription';
                 }
             } else {
                 if ($type == 'membership') {
                     $this->purchaseObject->description = 'Membership on ' . $app->getFullName();
                     if ($cost = $app->getConfigVar('gc_membership_cost_' . strtolower($bill_cycle))) {
                         $this->purchaseObject->cost = $cost;
                         $this->purchaseObject->bill_cycle = $bill_cycle . 'ly Subscription';
                     }
                 } else {
                     if ($type == 'subscription') {
                         $type_id_arr = explode("~", $type_id);
                         $product_details = GcrProductsTable::getProductDetails($type_id_arr[0], $type_id_arr[1], $app_id);
                         foreach ($product_details as $product) {
                             $this->purchaseObject->description = 'Subscription for - ' . $product->getFullName();
                             $this->purchaseObject->cost = $product->getCost();
                             $this->purchaseObject->bill_cycle = $bill_cycle . 'ly Subscription';
                         }
                     } else {
                         if ($type == 'sale') {
                             if ($purchase_item = Doctrine::getTable('GcrPurchaseItem')->find($type_id)) {
                                 $this->purchaseObject->description = $purchase_item->getDescription();
                                 $this->purchaseObject->cost = $purchase_item->getAmount();
                             }
                         }
                     }
                 }
             }
         }
     }
 }