private function constructDefault($errorKey = null) { $user = $this->getUser(); $output = $this->getOutput(); $balance = 0; if ($user->isLoggedIn()) { $balance = TMRecord::getTrueBalanceFromDB($user->getId()); } # Set Minimum payment value (regarding banking fees) $min = max(-$balance, 5); $defaultAmount = ''; # Building the pending transaction table and sum if ($balance < 0) { $defaultAmount = $min; $table = new TransactionsTablePager(); $table->setSelectFields(array('tmr_desc', 'tmr_date_created', 'tmr_amount', 'tmr_currency')); $table->setSelectConds(array('tmr_user_id' => $user->getId(), 'tmr_status' => 'PE', 'tmr_amount < 0', 'tmr_currency' => 'EUR')); $table->setFieldSortable(false); $tableHtml = $table->getBody(); } # We check if the user has some pending transaction to pay # We are using the HTMLFormS Helper # That's the way to create a form $formDescriptor = array('amount' => array('label-message' => 'ep-cd-amountlabel', 'section' => 'section1', 'type' => 'float', 'required' => 'true', 'help-message' => array('ep-help-amount', $min), 'min' => $min, 'max' => 9000000, 'default' => $defaultAmount, 'filter-callback' => array($this, 'filterAmount')), 'mail' => array('label-message' => 'youremail', 'section' => 'section1', 'type' => 'email', 'required' => 'true', 'validation-callback' => array($this, 'validateEmail'), 'help-message' => 'ep-help-mail')); # If user has an email registered, don't let him change it if (!(($mail = $user->getEmail()) == '')) { $formDescriptor['mail']['default'] = $user->getEmail(); #@FIXME: If form disabled $formDescriptor['mail']['disabled'] = true; } $htmlForm = new HTMLFormS($formDescriptor, 'ep-cd'); $htmlForm->setSubmitText(wfMsg('next')); $htmlForm->setTitle($this->getTitle()); $htmlForm->setSubmitCallback(array($this, 'initAttempt')); if ($balance < 0) { $htmlForm->addHeaderText(wfMessage('ep-default-formheader') . ' ' . wfMessage('ep-default-formheader-pending', $this->getLanguage()->formatNum(-$balance), 'cur-euro') . $tableHtml); $htmlForm->addFooterText(wfMessage('ep-default-formfooter-pending')); } else { $htmlForm->addHeaderText(wfMessage('ep-default-formheader')); } if (isset($errorKey)) { $output->addHTML($htmlForm->getErrors(wfMessage("ep-{$errorKey}"))); } $htmlForm->show(); }
private function displayList() { $output = $this->getOutput(); $user = $this->getUser(); $table = new TransactionsTablePager(); $table->setSelectFields(array('tmr_id', 'tmr_desc', 'tmr_date_created', 'tmr_amount', 'tmr_currency', 'tmr_status', 'tmr_tmb_id')); $table->setSelectConds(array('tmr_user_id' => $user->getId(), 'tmr_currency' => 'EUR')); $table->setHeader(wfMessage('tm-balance', $this->getLanguage()->formatNum(TMRecord::getTrueBalanceFromDB($user->getId())), 'cur-euro')->parse() . ' ' . wfMessage('tm-table-desc')->parse()); $output->addHtml($table->getWholeHtml()); }