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');
 }
Esempio n. 2
0
 function _error($sMsg)
 {
     global $aPagesFirstLine;
     $iLine = $aPagesFirstLine[$this->sPageName] + min($this->iLine, count($this->aPage) - 1);
     gcError($iLine, @$this->aPage[$this->iLine], $sMsg);
 }