public function setCommissionFee($fee = false) { if ($fee) { $this->commission_fee = $fee; } else { $institution = $this->my_purchase->getPurchaserInstitution(); $eschool = $this->my_purchase->getPurchaseTypeApp(); $this->commission_fee = GcrPurchaseTable::getCommissionFee($institution, $eschool); } }
public static function executeAccountingCron() { $institutions = Doctrine_Core::getTable('GcrInstitution')->findAll(); foreach ($institutions as $institution) { // test code //if ($institution->getShortName() != 'globalsandbox') continue; GcrPurchaseTable::clearPendingTransactions(60 * 60 * 24); $institution->getAccountManager()->updateAccounting(array('update_eclassrooms' => true, 'verbose' => true)); } }
Please enter the total amount withdrawn, the check number or paypal transaction ID, and address information if applicable. </p> <p> <?php print $user->getFullNameString(); ?> has an account balance of <?php print GcrPurchaseTable::gc_format_money($account_balance); ?> , with a maximum withdrawal amount of <?php print GcrPurchaseTable::gc_format_money($max_withdrawal); ?> . This reflects a required minimum balance of <?php print GcrPurchaseTable::gc_format_money($min_balance); ?> . </p> <p><b>Submitting this form WILL NOT trigger an automatic payment via PayPal.</b></p> <p> If the funds still need to be transferred, either do: <ol> <li>Make a standard withdrawal request for the user and then approve it.</li> <li>Use PayPal's Virtual Terminal to send payment, and then save the transaction details here.</li> <li>Send a check by mail and save the payment details here.</li> </ol> </p> </div> </td> </tr> <tr>
$id = 'gcr_course_' . $eschool->getShortName() . '_' . $mdl_course->id; $img_src = $course_list_item->getCourseIconUrl(); $mdl_user = $course_list_item->getInstructor(); $summary = $course_list_item->getSummary(); $enrol_count = $course_list_item->getActiveUserCount(); $shortsummary = GcrInstitutionTable::formatStringSize($summary, 250, 21); if ($mdl_user) { $teacher_text = GcrEschoolTable::getInstructorProfileHtml($mdl_user); } else { $teacher_text = 'None'; } $fullname = GcrInstitutionTable::formatStringSize($mdl_course->fullname, 60, 30); $cost = $course_list->getCost(); $cost_text = ''; if ($cost) { $cost_text = 'Price: ' . GcrPurchaseTable::gc_format_money($cost); } ?> <div class="gc_course_list_item col2"> <?php if (isset($request_params["mode_id"]) && $request_params["mode_id"] != "" && $meta_data) { print '<span class="coursebox" end_index="' . $meta_data . '"></span>'; } ?> <div id="<?php print $id; ?> " class="gc_course_list_item_container"> <div class="gc_course_list_item_header"> <div class="gc_course_list_item_title gc_course_list_item_container_element "> <a title="<?php
print $payment_date_class; ?> ><?php print $payment_date; ?> </span></td> <td><?php print $payoff->getPayoffTypeString(); ?> </td> <td><?php print GcrPurchaseTable::gc_format_money($account_balance); ?> </td> <td><?php print GcrPurchaseTable::gc_format_money($amount); ?> </td> <?php if ($payoff->isPending()) { ?> <td> <form action="<?php print GcrEschoolTable::getHome()->getUrl() . '/homeadmin/approvePayoff?id=' . $payoff->getId(); ?> " method="POST"> <button type="submit" class="approvePayoffButton form_button button">Approve</button> </form> </td> <?php } else {
public function getPurchases($type = false, $start_ts = 0, $end_ts = null, $include_all_recurring = false, $include_manual = true) { return GcrPurchaseTable::getAppPurchases($this, $type, $start_ts, $end_ts, $include_all_recurring, $include_manual); }
public function getPurchases($type = false, $start_ts = 0, $end_ts = null, $include_all_recurring = false, $include_manual = true) { $purchases = GcrPurchaseTable::getAppPurchases($this, $type, $start_ts, $end_ts, $include_all_recurring, $include_manual); $eschools = $this->getEschools(); if ($eschools) { foreach ($eschools as $eschool) { if ($eschool_purchases = GcrPurchaseTable::getAppPurchases($eschool, $type, $start_ts, $end_ts, $include_all_recurring, $include_manual)) { if ($purchases) { $purchases->merge($eschool_purchases); } else { $purchases = $eschool_purchases; } } } } return $purchases; }
<tr> <td>Pending Withdrawal: </td> <td class="total"><?php print GcrPurchaseTable::gc_format_money($withdrawal->getAmount()); ?> </td> </tr> <?php } } else { ?> <tr> <td>Total of Purchases: </td> <td class="total"><?php print GcrPurchaseTable::gc_format_money($total_gross); ?> </td> </tr> <?php } ?> </table> </div> <div style="clear:both"> <?php print $record_count . ' Transaction'; print $record_count > 1 || $record_count == 0 ? 's' : ''; if ($gc_admin) { ?> <span style="float:right"><button class="adminOptionsButton smallButton" user_id="<?php
/purchase/classroomPurchase"> <table class="gc_small_form"> <th>Learning Institution</th><th>Pricing Options</th> <?php $options = array(); $selected = true; foreach ($eschools as $eschool) { $row1 = true; print '<tr><td><b>' . $eschool->getFullName() . '</b></td><td>'; $options['Month'] = $eschool->getConfigVar('gc_classroom_cost_month'); $options['Year'] = $eschool->getConfigVar('gc_classroom_cost_year'); foreach ($options as $key => $value) { if (!$row1) { print '<br />'; } print '<input type="radio" name="eschool_id" '; if ($selected) { print 'checked="checked" '; $selected = false; } print 'value="' . $eschool->getShortName() . '#' . $key . '">'; print GcrPurchaseTable::gc_format_money($value) . '/' . $key . '</input>'; $row1 = false; } print '</td></tr>'; } ?> </table> <br /><br /><input type="submit" class="button" value="Continue" /> </form> </div>
<td> <a href="<?php print "https://" . $data_item['eschool']->getShortName() . "." . gcr::domainName; ?> " target="_blank"> <?php print $name_text; ?> </a> </td> <td><?php print $owner_html; ?> </td> <td style="width:70px;"><?php print GcrPurchaseTable::gc_format_money($data_item['balance']); ?> </td> <td style="width:70px;"><?php print $data_item['created']; ?> </td> <td><?php print $data_item['status']; ?> </td> <td style="width:70px;"><span<?php print $date_class; ?> ><?php print $data_item['date'];
public function getNextPaymentDate() { $manual_payment_ts = $this->getManualPaymentEndDate(); $purchase = $this->getPurchase(); if (!$purchase) { if ($manual_payment_ts == 0) { return false; } else { return $manual_payment_ts; } } $paypal_records = Doctrine::getTable('GcrPaypal')->findByRecurringPaymentId($purchase->profile_id); if (count($paypal_records) == 0) { $next_payment_ts = $purchase->trans_time; } else { $most_recent_payment = null; foreach ($paypal_records as $record) { if (!$most_recent_payment || $record->getPaymentDate() > $most_recent_payment->getPaymentDate()) { $most_recent_payment = $record; } } $next_payment_ts = GcrPurchaseTable::getNextBillingDate($most_recent_payment->getPaymentDate(), $purchase->bill_cycle); } if ($manual_payment_ts < $next_payment_ts) { return $next_payment_ts; } else { return $manual_payment_ts; } }
protected function getSalesCell($eclassroom) { $mhr_user = $eclassroom->getUser(); $content = '<a href="' . $this->institution->getUrl() . '/account/view?user='******'" target="_blank">' . GcrPurchaseTable::gc_format_money($this->current_item_amounts['sales']) . '</a>'; return new GcrTableCell(array(), $content); }
protected function getBalanceCell($ts, $item) { $content = GcrPurchaseTable::gc_format_money($item->getOwnerBalance()); return new GcrTableCell(array(), $content); }
</td> </tr> <tr> <td>Available Balance: </td> <td class="total"><?php print GcrPurchaseTable::gc_format_money($account_balance); ?> </td> </tr> <?php if ($withdrawal) { ?> <tr> <td>Pending Withdrawal: </td> <td class="total"><?php print GcrPurchaseTable::gc_format_money($withdrawal->getAmount()); ?> </td> </tr> <?php } ?> </table> </div> <div style="clear:both"> <?php print $account_table->getTotal('record_count'); ?> Transactions <?php if ($gc_admin) {
</small> </div> <div id="accountTotals"> <br /> <table> <tr> <td>Total Number of Courses: </td> <td class="total"><?php print $eclassroom_table->getTotal('total_courses'); ?> </td> </tr> <tr> <td>Total Sales: </td> <td class="total"><?php print GcrPurchaseTable::gc_format_money($eclassroom_table->getTotal('total_sales')); ?> </td> </tr> </table> </div> <br /><br /> <div style="clear:both"> <small> <?php $record_count = $eclassroom_table->getTotal('record_count'); print $record_count . ' eClassroom'; print $record_count != 1 ? 's' : ''; if ($CFG->current_app->hasPrivilege('GCUser')) { ?> <span style="float:right">
public function emailInfoToGC($params = array()) { $app = $this->getPurchaseTypeApp(); $user_institution = $this->getPurchaserInstitution(); $mhr_user = $this->getPurchaserUser(); $mhr_user_obj = $mhr_user->getObject(); $params['eschool'] = $app; $params['user_eschool'] = $user_institution; $params['time'] = "Time " . date("D: m/d/Y H:i"); $params['user_info'] = "{$mhr_user_obj->username}: {$mhr_user_obj->firstname} {$mhr_user_obj->lastname} ({$mhr_user_obj->email}) @ {$user_institution->getFullName()} ({$user_institution->getShortName()})"; $params['eschool_info'] = "{$app->getFullName()} ({$app->getShortName()})"; $params['sales_info'] = "Total: " . GcrPurchaseTable::gc_format_money($this->amount); $params['purchase_id'] = $this->id; $to = gcr::gcPurchaseNotification; $subject = "Purchase ID# " . $this->id; $from = "*****@*****.**"; //set the headers $replyto = "*****@*****.**"; $email = new GcrEmailer('purchase_info', $to, $subject, $params, $from, $replyto); $email->sendHtmlEmail(); }
public function executeDoManualPayoff(sfWebRequest $request) { global $CFG; $CFG->current_app->requireLogin(); $this->current_user = $CFG->current_app->getCurrentUser(); if (!$this->current_user->getRoleManager()->hasPrivilege('GCUser')) { $CFG->current_app->gcError('Non-privileged attempted access to ' . $form['user_eschool_id'] . ' createWithdrawal with user ID ' . $form['user_id'], 'gcpageaccessdenied'); } $form = $request->getPostParameters(); if ($form['payoff_id'] != '') { if (!($this->payoff = Doctrine::getTable('GcrPayoff')->find($form['payoff_id']))) { $CFG->current_app->gcError('Payoff ID: ' . $form['id'] . ' does not exist', 'gcdatabaseerror'); } if (!$this->payoff->isManual()) { $CFG->current_app->gcError('Payoff ID ' . $this->payoff->getId() . ' is not of type manual', 'gcdatabaseerror'); } $this->institution = GcrInstitutionTable::getInstitution($this->payoff->getEschoolId()); $user_institution = GcrInstitutionTable::getInstitution($this->payoff->getUserEschoolId()); if (!($this->user = $user_institution->getUserById($this->payoff->getUserId()))) { $CFG->current_app->gcError('Local User with ID ' . $this->payoff->getUserId() . ' on eschool ' . $user_institution->getShortName() . ' does not exist', 'gcdatabaseerror'); } if (!($this->credentials = $this->payoff->getCredentials())) { $CFG->current_app - gcError('Payoff ID ' . $this->payoff->getId() . ' has no credentials', 'gcdatabaserror'); } if (!($purchase = $this->payoff->getPurchase())) { $CFG->current_app->gcError('Payoff ID ' . $this->payoff->getId() . ' purchase ID ' . $this->payoff->getPurchaseId() . ' does not exist.', 'gcdatabaseerror'); } } else { $this->institution = GcrInstitutionTable::getInstitution($form['eschool_id']); $user_institution = GcrInstitutionTable::getInstitution($form['user_eschool_id']); if (!($this->user = $user_institution->getUserById($form['user_id']))) { $CFG->current_app->gcError('Local User with ID ' . $form['user_id'] . ' on eschool ' . $user_institution->getShortName() . ' does not exist', 'gcdatabaseerror'); } if (!($this->credentials = $this->user->getAccountManager()->getPayoffCredentials())) { $CFG->current_app->gcError('No payoff credentials found for ' . $form['user_eschool_id'] . ' createWithdrawal with user ID ' . $form['user_id'], 'gcpageaccessdenied'); } $this->payoff = new GcrPayoff(); $this->payoff->setUserId($this->user->getObject()->id); $this->payoff->setUserEschoolId($form['user_eschool_id']); $this->payoff->setEschoolId($form['eschool_id']); $this->payoff->setPayoffStatus('completed'); $this->payoff->setCredentialsId($this->credentials->getId()); } unset($form['payoff_id']); $manual_payoff_form = new GcrPayoffManualForm(); $manual_payoff_form->bind($form); if ($manual_payoff_form->isValid()) { $this->payoff->setAmount($form['amount']); $form['transtime'] = GcrPurchaseTable::convertDatetoTimestamp($form['transtime']); $this->payoff->setTransTime($form['transtime']); $this->payoff->setPayoffType($this->user->getAccountManager()->getPayoffType() . '_manual'); $url = GcrEschoolTable::getHome()->getUrl() . '/account/view?eschool=' . $this->institution->getShortName() . '&user='******'type'] == 'check') { if ($this->payoff->isManualCheckPayment()) { if (!($address = $this->payoff->getAddressObject())) { $CFG->current_app->gcError('Payoff ID ' . $this->payoff->getId() . ' has non-existant address value'); } } else { $address = new GcrAddress(); } $address->setStreet1($form['street1']); $address->setStreet2($form['street2']); $address->setCity($form['city']); $address->setZipcode($form['zipcode']); $address->setState($form['state']); $address->setCountry($form['country']); $address->save(); $this->payoff->setAddress($address->getId()); } if ($form['description'] == '') { $description = 'Manual Account Withdrawal'; } else { $description = $form['description']; } if ($purchase) { $purchase->setPurchaseTypeDescription($description); $purchase->setAmount($this->payoff->getAmount()); $purchase->setTransTime($form['transtime']); $purchase->setProfileId($form['reference_id']); $purchase->save(); } else { $purchase = $this->payoff->createPurchaseRecord($description, $form['transtime'], $form['reference_id']); } $this->payoff->save(); $purchase->updateRelatedAccounting(); $this->redirect($url); } $this->payoff_id = $this->payoff->getId(); $this->payoff_form = $manual_payoff_form; $this->setTemplate('manualPayoff'); }
$img_src = $course_list_item->getCourseIconUrl(); $mdl_user = $course_list_item->getInstructor(); $summary = $course_list_item->getSummary(); $enrol_count = $course_list_item->getActiveUserCount(); $shortsummary = GcrInstitutionTable::formatStringSize($summary, 250, 21); if ($mdl_user) { $teacher_text = GcrEschoolTable::getInstructorProfileHtml($mdl_user); } else { $teacher_text = 'None'; } $fullname = GcrInstitutionTable::formatStringSize($mdl_course->fullname, 60, 30); $cost = $course_list->getCost(); $cost_text = ''; //if ($cost) { //$cost_text = 'Price: ' . GcrPurchaseTable::gc_format_money($cost); $cost_text = GcrPurchaseTable::gc_format_money($cost); //} $enrollment_status = false; $current_user = $CFG->current_app->getCurrentUser(); if ($current_user->getRoleManager()->hasPrivilege('Student')) { $mdl_roles = $course_list->getRoleAssignments($current_user); $enrollment_status = $mdl_roles && count($mdl_roles > 0); } ?> <tr> <td width="20%"><?php print $fullname; ?> </td> <td width="15%"><span style="color:green;"><?php print $cost_text;
public function executeDoManualMembership(sfWebRequest $request) { $this->authorizeUser(); global $CFG; $form = $request->getPostParameters(); if ($form['id'] != '') { // Edit of existing purchase $purchase = $this->getManualPurchase($form['id'], 'membership'); $institution = $this->eschool->getInstitution(); if (!($mhr_user = $institution->selectFromMhrTable('usr', 'id', $form['purchase_user_field'], true))) { $CFG->current_app->gcError('Invalid user ID ' . $form['purchase_user_field'], 'gcdatabaseerror'); } $manual_purchase_form = new GcrPurchaseMembershipManualForm($purchase, array('eschool' => $institution)); $form['user_id'] = $mhr_user->id; $form['amount'] = $form['amount_field']; $form['gc_fee'] = $this->eschool->getGcFeeMembership(); $form['bill_cycle'] = GcrPurchaseTable::convertDatetoTimestamp($form['bill_cycle']); $form['trans_time'] = GcrPurchaseTable::convertDatetoTimestamp($form['trans_time']); $manual_purchase_form->bind($form); if ($manual_purchase_form->isValid()) { $purchase = $manual_purchase_form->save(); $purchase->updateRelatedAccounting(); $this->redirect($CFG->current_app->getUrl() . '/account/view?eschool=' . $institution->getShortName()); } } else { // New purchase if ($short_name = $form['user_institution_id']) { $this->eschool = GcrInstitutionTable::getInstitution($short_name); } else { $CFG->current_app->gcError('eSchool Parameter Missing', 'gcdatabaseerror'); } $institution = $this->eschool->getInstitution(); $manual_purchase_form = new GcrPurchaseMembershipManualForm(array(), array('eschool' => $institution)); $form['purchase_type'] = 'membership_manual'; $form['purchase_type_description'] = 'Manual Membership Transaction'; $form['purchase_type_quantity'] = 1; $form['purchase_type_id'] = $institution->getShortName(); $form['user_id'] = $form['purchase_user_field']; $form['purchase_type_eschool_id'] = $institution->getShortName(); $form['user_institution_id'] = $institution->getShortName(); $form['amount'] = $form['amount_field']; $form['gc_fee'] = $institution->getGcFeeMembership(); $form['owner_fee'] = 0; $form['seller_id'] = 0; $form['bill_cycle'] = GcrPurchaseTable::convertDatetoTimestamp($form['bill_cycle']); $form['trans_time'] = GcrPurchaseTable::convertDatetoTimestamp($form['trans_time']); $manual_purchase_form->bind($form); if ($manual_purchase_form->isValid()) { if (!$institution->getUserById($form['purchase_user_field'])) { $CFG->current_app->gcError('Invalid user ID ' . $form['purchase_user_field'], 'gcdatabaseerror'); } $purchase = $manual_purchase_form->save(); $purchase->assignSeller(); $purchase->updateRelatedAccounting(); $this->redirect($CFG->current_app->getUrl() . '/account/view?eschool=' . $institution->getShortName()); } } $this->memerbship_form = $manual_purchase_form; $this->setTemplate('manualMembership'); }