function Currencies() { return EcommerceCurrency::get_list(); }
/** * STANDARD SILVERSTRIPE STUFF * broken up into submitted and not (yet) submitted **/ function getCMSFields() { $fields = parent::getCMSFields(); $currentMember = Member::currentUser(); if (!$this->exists() || !$this->StatusID) { $firstStep = OrderStep::get()->First(); $this->StatusID = $firstStep->ID; $this->write(); } $submitted = $this->IsSubmitted() ? true : false; if ($submitted) { //TODO //Having trouble here, as when you submit the form (for example, a payment confirmation) //as the step moves forward, meaning the fields generated are incorrect, causing an error //"I can't handle sub-URLs of a Form object." generated by the RequestHandler. //Therefore we need to try reload the page so that it will be requesting the correct URL to generate the correct fields for the current step //Or something similar. //why not check if the URL == $this->CMSEditLink() //and only tryToFinaliseOrder if this is true.... if ($_SERVER['REQUEST_URI'] == $this->CMSEditLink() || $_SERVER['REQUEST_URI'] == $this->CMSEditLink("edit")) { $this->tryToFinaliseOrder(); } } else { $this->init(true); $this->calculateOrderAttributes(true); Session::set("EcommerceOrderGETCMSHack", $this->ID); } if ($submitted) { $this->fieldsAndTabsToBeRemoved[] = "CustomerOrderNote"; } else { $this->fieldsAndTabsToBeRemoved[] = "Emails"; } foreach ($this->fieldsAndTabsToBeRemoved as $field) { $fields->removeByName($field); } $fields->insertAfter(new Tab("Next", new HeaderField("MyOrderStepHeader", _t("Order.CURRENTSTATUS", "1. Current Status")), $this->OrderStepField(), new HeaderField("OrderStepNextStepHeader", _t("Order.ACTIONNEXTSTEP", "2. Action Next Step")), new LiteralField("OrderStepNextStepHeaderExtra", "<p><strong>" . _t("Order.NEEDTOREFRESH", "If you have made any changes to the order then you will have to refresh or save this record to see up-to-date options here.") . "</strong></p>"), new HeaderField("ActionNextStepManually", _t("Order.MANUALSTATUSCHANGE", "3. Move Order Along")), new LiteralField("StatusIDExplanation", "<h3><a href=\"" . $this->CMSEditLink() . "\" class=\"action ss-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only\"><span class=\"ui-button-text\">" . _t("Order.REFRESH", "refresh now") . "</span></a></h3>")), "Main"); $this->MyStep()->addOrderStepFields($fields, $this); if ($submitted) { //Config::nest(); //Config::inst()->update('SSViewer', 'theme_enabled', true); //$htmlSummary = $this->renderWith("Order"); //Config::unnest(); $fields->addFieldToTab('Root.Main', new LiteralField('MainDetails', '<iframe src="' . $this->PrintLink() . '" width="100%" height="500"></iframe>')); $fields->insertAfter(new Tab("Emails", $this->getEmailsTableField()), "Next"); $fields->addFieldToTab('Root.Payments', $this->getPaymentsField()); $fields->addFieldToTab("Root.Payments", new ReadOnlyField("TotalPaid", _t("Order.TOTALPAID", "Total Paid"), $this->getTotalPaid())); $fields->addFieldToTab("Root.Payments", new ReadOnlyField("TotalOutstanding", _t("Order.TOTALOUTSTANDING", "Total Outstanding"), $this->getTotalOutstanding())); if ($this->canPay()) { $link = EcommercePaymentController::make_payment_link($this->ID); $js = "window.open(this.href, 'payment', 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,width=800,height=600'); return false;"; $header = _t("Order.MAKEPAYMENT", "make payment"); $label = _t("Order.MAKEADDITIONALPAYMENTNOW", "make additional payment now"); $linkHTML = '<a href="' . $link . '" onclick="' . $js . '">' . $label . '</a>'; $fields->addFieldToTab("Root.Payments", new HeaderField("MakeAdditionalPaymentHeader", $header, 3)); $fields->addFieldToTab("Root.Payments", new LiteralField("MakeAdditionalPayment", $linkHTML)); } //member $member = $this->Member(); if ($member && $member->exists()) { $fields->addFieldToTab('Root.Account', new LiteralField("MemberDetails", $member->getEcommerceFieldsForCMS())); } else { $fields->addFieldToTab('Root.Customer', new LiteralField("MemberDetails", "<p>" . _t("Order.NO_ACCOUNT", "There is no --- account --- associated with this order") . "</p>")); } $cancelledField = $fields->dataFieldByName("CancelledByID"); $fields->removeByName("CancelledByID"); $fields->addFieldToTab("Root.Cancellation", DropdownField::create("CancelledByID", $cancelledField->Title(), array(0 => "--- " . _t("Order.NOT_CANCELLED", "Not Cancelled") . " ---", $currentMember->ID => _t("Order.CANCELLED_BY", "Cancelled By") . " " . $currentMember->getName()))); $fields->addFieldToTab('Root.Log', $this->getOrderStatusLogsTableField_Archived()); $submissionLog = $this->SubmissionLog(); if ($submissionLog) { $fields->addFieldToTab('Root.Log', new ReadonlyField('SequentialOrderNumber', _t("Order.SEQUENTIALORDERNUMBER", "Sequential order number for submitted orders (e.g. 1,2,3,4,5...)"), $submissionLog->SequentialOrderNumber)); } } else { $linkText = _t("Order.LOAD_THIS_ORDER", "load this order"); $message = _t("Order.NOSUBMITTEDYET", "No details are shown here as this order has not been submitted yet. You can {link} to submit it... NOTE: For this, you will be logged in as the customer and logged out as (shop)admin .", array("link" => '<a href="' . $this->RetrieveLink() . '" data-popup="true">' . $linkText . '</a>')); $fields->addFieldToTab('Root.Main', new LiteralField('MainDetails', '<p>' . $message . '</p>')); $fields->addFieldToTab('Root.Items', $this->getOrderItemsField()); $fields->addFieldToTab('Root.Extras', $this->getModifierTableField()); //MEMBER STUFF $specialOptionsArray = array(); if ($this->MemberID) { $specialOptionsArray[0] = _t("Order.SELECTCUSTOMER", "--- Remover Customer ---"); $specialOptionsArray[$this->MemberID] = _t("Order.LEAVEWITHCURRENTCUSTOMER", "- Leave with current customer: ") . $this->Member()->getTitle(); } elseif ($currentMember) { $specialOptionsArray[0] = _t("Order.SELECTCUSTOMER", "--- Select Customers ---"); $currentMemberID = $currentMember->ID; $specialOptionsArray[$currentMemberID] = _t("Order.ASSIGNTHISORDERTOME", "- Assign this order to me: ") . $currentMember->getTitle(); } //MEMBER FIELD!!!!!!! $memberArray = $specialOptionsArray + EcommerceRole::list_of_customers(); $fields->addFieldToTab("Root.Main", new DropdownField("MemberID", _t("Order.SELECTCUSTOMER", "Select Customer"), $memberArray), "CustomerOrderNote"); $memberArray = null; } $fields->addFieldToTab('Root.Addresses', new HeaderField("BillingAddressHeader", _t("Order.BILLINGADDRESS", "Billing Address"))); $fields->addFieldToTab('Root.Addresses', $this->getBillingAddressField()); if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) { $fields->addFieldToTab('Root.Addresses', new HeaderField("ShippingAddressHeader", _t("Order.SHIPPINGADDRESS", "Shipping Address"))); $fields->addFieldToTab('Root.Addresses', new CheckboxField("UseShippingAddress", _t("Order.USESEPERATEADDRESS", "Use separate shipping address?"))); if ($this->UseShippingAddress) { $fields->addFieldToTab('Root.Addresses', $this->getShippingAddressField()); } } $currencies = EcommerceCurrency::get_list(); if ($currencies && $currencies->count()) { $currencies = $currencies->map()->toArray(); $fields->addFieldToTab("Root.Currency", new ReadOnlyField("ExchangeRate ", _t("Order.EXCHANGERATE", "Exchange Rate"), $this->ExchangeRate)); $fields->addFieldToTab("Root.Currency", new DropdownField("CurrencyUsedID", _t("Order.CurrencyUsed", "Currency Used"), $currencies)); } else { $fields->addFieldToTab("Root.Currency", new LiteralField("CurrencyInfo", "<p>You can not change currencies, because no currencies have been created.</p>")); $fields->replaceField("CurrencyUsedID", $fields->dataFieldByName("CurrencyUsedID")->performReadonlyTransformation()); } $fields->addFieldToTab("Root.Log", new ReadonlyField("Created", _t("Root.CREATED", "Created"))); $fields->addFieldToTab("Root.Log", new ReadonlyField("LastEdited", _t("Root.LASTEDITED", "Last saved"))); $this->extend('updateSettingsFields', $fields); return $fields; }
/** * return null if there is less than two currencies in use * on the site. * @return DataList | Null */ function Currencies() { $list = EcommerceCurrency::get_list(); if ($list && $list->count() > 1) { return $list; } }