/** * Execute a command and return a response. Does not render * @param IRequest $Request * @return IResponse the execution response */ function execute(IRequest $Request) { $TransactionEntry = TransactionEntry::get($this->getTransactionID()); $transactionLog = $TransactionEntry->fetchLog(); $Invoice = $TransactionEntry->getInvoice(); $Product = $Invoice->getProduct(); $Wallet = $Invoice->getWallet(); $accounts = array(); $merchantProfit = $Product->calculateProfit($TransactionEntry->getStatus(), $accounts); $accounts[$Product->getAccountID()] = $merchantProfit; $ProfitTBody = new HTMLSequenceTableBody(new CallbackSequenceMap(function (ISequenceMapper $Map) use($accounts) { foreach ($accounts as $accountID => $profit) { $Map->mapNext(array('account' => $accountID, 'profit' => $profit)); } })); $Form = new HTMLForm(self::FORM_METHOD, $Request->getPath(), self::FORM_NAME, new HTMLMetaTag(HTMLMetaTag::META_TITLE, self::TITLE), new HTMLHeaderScript(__DIR__ . '/assets/transaction.js'), new HTMLHeaderStyleSheet(__DIR__ . '/assets/transaction.css'), new HTMLElement('fieldset', 'fieldset-transaction-info inline', new HTMLElement('legend', 'legend-transaction-info', 'Transaction Information'), new MapRenderer($TransactionEntry)), new HTMLElement('fieldset', 'fieldset-product-profit inline', new HTMLElement('legend', 'legend-product-profit', 'Profit Information'), new HTMLTable($ProfitTBody)), "<br/>", new HTMLElement('fieldset', 'fieldset-product-container inline', new HTMLElement('legend', 'legend-product', 'Order Information'), $Wallet->getFieldSet($Request)->setAttribute('disabled', 'disabled'), $Product->getOrderFieldSet($Request)->setAttribute('disabled', 'disabled'), $Product->getConfigFieldSet($Request)->setAttribute('disabled', 'disabled'), $Product->getFeesFieldSet($Request)->setAttribute('disabled', 'disabled'), "<br/><br/>", new HTMLButton('submit', 'Update', 'submit')), "<br/>", new HTMLElement('fieldset', 'fieldset-transaction-log inline', new HTMLElement('legend', 'legend-transaction-log', 'Transaction Log'), new HTMLTextAreaField(self::PARAM_LOG . '_disabled', $transactionLog, new Attributes('rows', 10, 'cols', 100), new Attributes('disabled', 'disabled')), "<br/>", new HTMLTextAreaField(self::PARAM_LOG, new Attributes('rows', 3, 'cols', 100)), "<br/>", new HTMLButton(self::PARAM_SUBMIT, 'Append', 'append-log')), new HTMLElement('fieldset', 'fieldset-transaction-manage inline', new HTMLElement('legend', 'legend-submit', self::TITLE), new HTMLInputField(self::PARAM_ID, $this->id, 'hidden', new RequiredValidation()), new HTMLElement('label', null, "Status<br/>", $SelectStatus = new HTMLSelectField(self::PARAM_TRANSACTION_STATUS, TransactionEntry::$StatusOptions, new RequiredValidation())), "<br/><br/>", new HTMLButton(self::PARAM_SUBMIT, 'Update', 'submit')), "<br/>"); $SelectStatus->setInputValue($TransactionEntry->getStatus()); if (!$Request instanceof IFormRequest) { return $Form; } switch ($Request[self::PARAM_SUBMIT]) { case 'submit': $status = $Form->validateField($Request, self::PARAM_TRANSACTION_STATUS); $TransactionEntry->update($Request, $status); ProfitEntry::update($Request, $TransactionEntry->getID()); return new RedirectResponse(ManageTransaction::getRequestURL($TransactionEntry->getID()), "Transaction updated successfully. Redirecting...", 5); case 'append-log': $appendLog = $Request[self::PARAM_LOG]; $TransactionEntry->appendLog($appendLog); return new RedirectResponse(ManageTransaction::getRequestURL($TransactionEntry->getID()), "Log appended successfully. Redirecting...", 5); default: throw new \InvalidArgumentException("Invalid Submit"); } }
/** * Execute a command and return a response. Does not render * @param IRequest $Request * @throws RequestException * @throws \CPath\Request\Validation\Exceptions\ValidationException * @throws \Exception * @return IResponse the execution response */ function execute(IRequest $Request) { $SessionRequest = $Request; if (!$SessionRequest instanceof ISessionRequest) { throw new \Exception("Session required"); } $AccountEntry = AccountEntry::get($this->id); $Account = $AccountEntry->getAccount(); $AffiliateQuery = AccountAffiliationEntry::queryAccountAffiliates($Account->getID()); $AffiliateListTable = new HTMLPDOQueryTable($AffiliateQuery); $AffiliateListTable->addColumn('affiliate'); $AffiliateListTable->addColumn('type'); $Form = new HTMLForm(self::FORM_METHOD, $Request->getPath(), self::FORM_NAME, new HTMLMetaTag(HTMLMetaTag::META_TITLE, self::TITLE), new HTMLHeaderScript(__DIR__ . '/assets/account.js'), new HTMLHeaderStyleSheet(__DIR__ . '/assets/account.css'), new HTMLElement('fieldset', 'fieldset-manage inline', new HTMLElement('legend', 'legend-manage', self::TITLE), new HTMLInputField(self::PARAM_ID, $this->id, 'hidden'), new HTMLInputField(self::PARAM_ACCOUNT_TYPE, $Account->getTypeName(), 'hidden'), new HTMLElement('label', null, "Status<br/>", $SelectStatus = new HTMLSelectField(self::PARAM_ACCOUNT_STATUS, AccountEntry::$StatusOptions, new RequiredValidation())), "<br/><br/>", $Account->getFieldSet($Request), "<br/><br/>", new HTMLButton(self::PARAM_SUBMIT, 'Update', 'update'), new HTMLButton(self::PARAM_SUBMIT, 'Delete', 'delete')), new HTMLElement('fieldset', 'fieldset-affiliates inline', new HTMLElement('legend', 'legend-affiliates', "Add affiliation"), "Account ID:<br/>", new HTMLInputField(self::PARAM_AFFILIATE_ID), "<br/><br/>Affiliation Type:<br/>", $TypeSelect = new HTMLSelectField(self::PARAM_AFFILIATE_TYPE, array("Request New Affiliate" => AccountAffiliationEntry::TYPE_REQUEST_AFFILIATE, "Request New Reseller" => AccountAffiliationEntry::TYPE_REQUEST_RESELLER, "Request New Processor" => AccountAffiliationEntry::TYPE_REQUEST_PROCESSOR)), "<br/><br/>", new HTMLButton(self::PARAM_SUBMIT, 'Request', 'request')), new HTMLElement('fieldset', 'fieldset-affiliate-list inline', new HTMLElement('legend', 'legend-affiliate-list', "Affiliates"), $AffiliateListTable), new HTMLElement('fieldset', 'fieldset-affiliate-approve inline', new HTMLElement('legend', 'legend-affiliate-approve', "Approve Affiliates"), $ApproveSelect = new HTMLSelectField(self::PARAM_APPROVE_AFFILIATE_ID, array('Pending affiliate approvals' => null)), "<br/><br/>", new HTMLButton(self::PARAM_SUBMIT, 'Approve', 'approve'))); $SelectStatus->setInputValue($AccountEntry->getStatus()); $Account = AbstractAccountType::loadFromSession($SessionRequest); if ($Account instanceof AdministratorAccount) { $TypeSelect->setOptions(AccountAffiliationEntry::$TypeOptions); } $AffiliateQuery->addRowCallback(function (AccountAffiliationEntry $Affiliation) use($Account, $ApproveSelect) { if ($Affiliation->getType() & $Affiliation::TYPE_REQUEST_RESELLER && $Affiliation->getAffiliateID() === $Account->getID()) { $ApproveSelect->addOption($Affiliation->getAffiliateID(), "Approve '" . $Affiliation->getTypeText() . "' - " . $Affiliation->getAffiliateID()); } }); if (!$Request instanceof IFormRequest) { return $Form; } $submit = $Request[self::PARAM_SUBMIT]; switch ($submit) { case 'update': $status = $Form->validateField($Request, self::PARAM_ACCOUNT_STATUS); $AccountEntry->update($Request, $Account, $status); return new RedirectResponse(ManageAccount::getRequestURL($this->getAccountID()), "Account updated successfully. Redirecting...", 5); case 'delete': AccountEntry::delete($Request, $this->getAccountID()); return new RedirectResponse(SearchAccounts::getRequestURL(), "Account deleted successfully. Redirecting...", 5); case 'approve': $affiliateID = $Form->validateField($Request, self::PARAM_APPROVE_AFFILIATE_ID); AccountAffiliationEntry::approveAffiliation($Request, $this->getAccountID(), $affiliateID); return new RedirectResponse(SearchAccounts::getRequestURL(), "Account deleted successfully. Redirecting...", 5); case 'request': $affiliateID = $Form->validateField($Request, self::PARAM_AFFILIATE_ID); $type = $Form->validateField($Request, self::PARAM_AFFILIATE_TYPE); AccountAffiliationEntry::setAffiliate($Request, $this->getAccountID(), $affiliateID, $type); return new RedirectResponse(ManageAccount::getRequestURL($this->getAccountID()), "Affiliation requested successfully. Redirecting...", 5); } throw new \InvalidArgumentException($submit); }
/** * Execute a command and return a response. Does not render * @param IRequest $Request * @throws \Exception * @return IResponse the execution response */ function execute(IRequest $Request) { $SessionRequest = $Request; if (!$SessionRequest instanceof ISessionRequest) { throw new \Exception("Session required"); } $Form = new HTMLForm(self::FORM_METHOD, $Request->getPath(), self::FORM_NAME, new HTMLMetaTag(HTMLMetaTag::META_TITLE, self::TITLE), new HTMLHeaderScript(__DIR__ . '/assets/account.js'), new HTMLHeaderStyleSheet(__DIR__ . '/assets/account.css'), new HTMLElement('fieldset', 'fieldset-create-account', new HTMLElement('legend', 'legend-account', self::TITLE), new HTMLElement('label', null, "Choose a Account Type<br/>", new HTMLInputField(self::PARAM_ACCOUNT_NAME, new RequiredValidation())), "<br/><br/>", new HTMLElement('label', null, "Status<br/>", new HTMLInputField(self::PARAM_ACCOUNT_PASSWORD, null, 'password', new RequiredValidation())), "<br/><br/>Login:<br/>", new HTMLButton('submit', 'Login', 'submit')), "<br/>"); $Form->setFormValues($Request); if (!$Request instanceof IFormRequest) { return $Form; } $Form->validateRequest($Request); $AccountEntry = AccountEntry::search($Request[self::PARAM_ACCOUNT_NAME]); $Account = $AccountEntry->getAccount(); $Account->assertPassword($Request[self::PARAM_ACCOUNT_PASSWORD]); $Account->startSession($SessionRequest); return new RedirectResponse(ManageAccount::getRequestURL($AccountEntry->getID()), "Logged in successfully. Redirecting...", 5); }
/** * Execute a command and return a response. Does not render * @param IRequest $Request * @throws \Exception * @return IResponse the execution response */ function execute(IRequest $Request) { $SessionRequest = $Request; if (!$SessionRequest instanceof ISessionRequest) { throw new \Exception("Session required"); } $Account = AbstractAccountType::loadFromSession($SessionRequest); $Form = new HTMLForm(self::FORM_METHOD, $Request->getPath(), self::FORM_NAME, new HTMLMetaTag(HTMLMetaTag::META_TITLE, self::TITLE . ' - ' . $Account->getAccountName()), new HTMLHeaderScript(__DIR__ . '/assets/account.js'), new HTMLHeaderStyleSheet(__DIR__ . '/assets/account.css'), new HTMLElement('fieldset', 'fieldset-create-account', new HTMLElement('legend', 'legend-account', self::TITLE . ' - ' . $Account->getAccountName()), new HTMLButton('submit', 'Logout', 'submit')), "<br/>"); $Form->setFormValues($Request); if (!$Request instanceof IFormRequest) { return $Form; } $Form->validateRequest($Request); if (!$SessionRequest->isStarted()) { $SessionRequest->startSession(); } $SessionRequest->destroySession(); return new RedirectResponse(Login::getRequestURL(), "Logged out successfully. Redirecting...", 5); }
/** * Execute a command and return a response. Does not render * @param IRequest $Request * @return IResponse the execution response */ function execute(IRequest $Request) { $WalletEntry = WalletEntry::get($this->id); $Wallet = $WalletEntry->getWallet(); $Form = new HTMLForm(self::FORM_METHOD, $Request->getPath(), self::FORM_NAME, new HTMLMetaTag(HTMLMetaTag::META_TITLE, self::TITLE . ': ' . $Wallet->getTitle()), new HTMLElement('fieldset', new HTMLElement('legend', 'legend-submit', self::TITLE . ': ' . $Wallet->getTitle()), new HTMLInputField(self::PARAM_ID, $this->id, 'hidden'), new HTMLElement('label', null, "Wallet Status<br/>", $Select = new HTMLSelectField(self::PARAM_WALLET_STATUS, WalletEntry::$StatusOptions, new RequiredValidation())), "<br/><br/>", $Wallet->getFieldSet($Request), "<br/><br/>", new HTMLButton(self::PARAM_SUBMIT, 'Update', 'update'), new HTMLButton(self::PARAM_SUBMIT, 'Delete', 'delete')), "<br/><br/>"); if (!$Request instanceof IFormRequest) { return $Form; } $Wallet->validateRequest($Request, $Form); $submit = $Request[self::PARAM_SUBMIT]; switch ($submit) { case 'update': $WalletEntry->update($Request, $Wallet); return new RedirectResponse(ManageWallet::getRequestURL($this->getWalletID()), "Wallet updated successfully. Redirecting...", 5); case 'delete': WalletEntry::delete($Request, $this->getWalletID()); return new RedirectResponse(SearchWallets::getRequestURL(), "Wallet deleted successfully. Redirecting...", 5); } throw new \InvalidArgumentException($submit); }
/** * Execute a command and return a response. Does not render * @param IRequest $Request * @throws RequestException * @return IResponse the execution response */ function execute(IRequest $Request) { $SessionRequest = $Request; if (!$SessionRequest instanceof ISessionRequest) { throw new RequestException("Session required"); } $ProductEntry = ProductEntry::get($this->id); $setRates = false; $Account = AbstractAccountType::loadFromSession($SessionRequest); if ($Account instanceof MerchantAccount) { if ($Account->getID() !== $ProductEntry->getAccountID()) { throw new RequestException("Product does not belong to merchant"); } } else { if ($Account instanceof AdministratorAccount) { $setRates = true; } else { throw new RequestException("Only merchants may create a new Product"); } } $Product = $ProductEntry->getProduct(); $sourceOptions = array("Choose a Payment Product" => null); $PaymentSourceTable = new PaymentSourceTable(); foreach ($PaymentSourceTable->fetchAll(1) as $PaymentSourceEntry) { $PaymentSource = $PaymentSourceEntry->getPaymentSource(); $sourceOptions[$PaymentSource->getTitle()] = $PaymentSourceEntry->getID(); } $Form = new HTMLForm(self::FORM_METHOD, $Request->getPath(), self::FORM_NAME, new HTMLMetaTag(HTMLMetaTag::META_TITLE, self::TITLE), new HTMLHeaderScript(__DIR__ . '/assets/product.js'), new HTMLHeaderStyleSheet(__DIR__ . '/assets/product.css'), new HTMLInputField(self::PARAM_ID, $this->id, 'hidden'), new HTMLInputField(self::PARAM_PRODUCT_TYPE, $Product->getTypeName(), 'hidden'), new HTMLElement('fieldset', new HTMLElement('legend', 'legend-order-page', "Try Order Page"), new HTMLAnchor(OrderForm::getRequestURL($this->getProductID()), "Order Page")), new HTMLElement('fieldset', 'fieldset-info inline', new HTMLElement('legend', 'legend-info', "Product Info"), new MapRenderer($ProductEntry)), new HTMLElement('fieldset', 'fieldset-config inline', new HTMLElement('legend', 'legend-config', self::TITLE), $Product->getConfigFieldSet($Request), $FeesFieldSet = $Product->getFeesFieldSet($Request), new HTMLElement('fieldset', 'fieldset-status inline', new HTMLElement('legend', 'legend-status', "Status"), $SelectStatus = new HTMLSelectField(self::PARAM_PRODUCT_STATUS, ProductEntry::$StatusOptions, new RequiredValidation())), "<br/><br/>", new HTMLButton(self::PARAM_SUBMIT, 'Update', 'update')), new HTMLElement('fieldset', 'inline', new HTMLElement('legend', 'legend-submit', "Delete Product"), new HTMLButton(self::PARAM_SUBMIT, 'Delete', 'delete')), "<br/>"); if (!$setRates) { $FeesFieldSet->setAttribute('disabled', 'disabled'); } $SelectStatus->setInputValue($ProductEntry->getStatus()); if (!$Request instanceof IFormRequest) { return $Form; } $submit = $Request[self::PARAM_SUBMIT]; switch ($submit) { case 'update': $status = $Request[self::PARAM_PRODUCT_STATUS]; $Product->validateConfigRequest($Request, $Form); $Product->validateFeesRequest($Request, $Form); $ProductEntry->update($Request, $Product, $status); return new RedirectResponse(ManageProduct::getRequestURL($this->getProductID()), "Product updated successfully. Redirecting...", 2); case 'delete': ProductEntry::delete($Request, $this->getProductID()); return new RedirectResponse(SearchProducts::getRequestURL(), "Product deleted successfully. Redirecting...", 8); } throw new \InvalidArgumentException($submit); }
/** * Execute a command and return a response. Does not render * @param IRequest $Request * @return IResponse the execution response */ function execute(IRequest $Request) { $Form = new HTMLForm(self::FORM_METHOD, $Request->getPath(), self::FORM_NAME, new HTMLMetaTag(HTMLMetaTag::META_TITLE, self::TITLE), new HTMLElement('fieldset', new HTMLElement('legend', 'legend-submit', self::TITLE), new HTMLButton('submit', 'Submit', 'submit')), "<br/>"); return $Form; }
function __construct(IRequest $Request) { $this->domain = $Request->getDomainPath(); }
/** * Execute a command and return a response. Does not render * @param IRequest $Request * @return IResponse the execution response */ function execute(IRequest $Request) { $Form = new HTMLForm(self::FORM_METHOD, $Request->getPath(), self::FORM_NAME, new HTMLMetaTag(HTMLMetaTag::META_TITLE, self::TITLE), new HTMLElement('fieldset', new HTMLElement('legend', 'legend-submit', self::TITLE), "Invoice ID:<br/>", new HTMLInputField(self::PARAM_ID, new RequiredValidation()), new HTMLButton('submit', 'Submit', 'submit')), "<br/>"); return $Form; }