/**
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::javascript(USERFORMS_DIR . '/javascript/Recipient.js');
     // Determine optional field values
     $form = $this->getFormParent();
     // predefined choices are also candidates
     $multiOptionFields = EditableMultipleOptionField::get()->filter('ParentID', $form->ID);
     // if they have email fields then we could send from it
     $validEmailFromFields = EditableEmailField::get()->filter('ParentID', $form->ID);
     // For the subject, only one-line entry boxes make sense
     $validSubjectFields = ArrayList::create(EditableTextField::get()->filter('ParentID', $form->ID)->exclude('Rows:GreaterThan', 1)->toArray());
     $validSubjectFields->merge($multiOptionFields);
     // To address cannot be unbound, so restrict to pre-defined lists
     $validEmailToFields = $multiOptionFields;
     // Build fieldlist
     $fields = FieldList::create(Tabset::create('Root')->addExtraClass('EmailRecipientForm'));
     // Configuration fields
     $fields->addFieldsToTab('Root.EmailDetails', array(FieldGroup::create(TextField::create('EmailSubject', _t('UserDefinedForm.TYPESUBJECT', 'Type subject'))->setAttribute('style', 'min-width: 400px;'), DropdownField::create('SendEmailSubjectFieldID', _t('UserDefinedForm.SELECTAFIELDTOSETSUBJECT', '.. or select a field to use as the subject'), $validSubjectFields->map('ID', 'Title'))->setEmptyString(''))->setTitle(_t('UserDefinedForm.EMAILSUBJECT', 'Email subject')), FieldGroup::create(TextField::create('EmailAddress', _t('UserDefinedForm.TYPETO', 'Type to address'))->setAttribute('style', 'min-width: 400px;'), DropdownField::create('SendEmailToFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASTO', '.. or select a field to use as the to address'), $validEmailToFields->map('ID', 'Title'))->setEmptyString(' '))->setTitle(_t('UserDefinedForm.SENDEMAILTO', 'Send email to'))->setDescription(_t('UserDefinedForm.SENDEMAILTO_DESCRIPTION', 'You may enter multiple email addresses as a comma separated list.')), TextField::create('EmailFrom', _t('UserDefinedForm.FROMADDRESS', 'Send email from'))->setDescription(_t('UserDefinedForm.EmailFromContent', "The from address allows you to set who the email comes from. On most servers this " . "will need to be set to an email address on the same domain name as your site. " . "For example on yoursite.com the from address may need to be something@yoursite.com. " . "You can however, set any email address you wish as the reply to address.")), FieldGroup::create(TextField::create('EmailReplyTo', _t('UserDefinedForm.TYPEREPLY', 'Type reply address'))->setAttribute('style', 'min-width: 400px;'), DropdownField::create('SendEmailFromFieldID', _t('UserDefinedForm.ORSELECTAFIELDTOUSEASFROM', '.. or select a field to use as reply to address'), $validEmailFromFields->map('ID', 'Title'))->setEmptyString(' '))->setTitle(_t('UserDefinedForm.REPLYADDRESS', 'Email for reply to'))->setDescription(_t('UserDefinedForm.REPLYADDRESS_DESCRIPTION', 'The email address which the recipient is able to \'reply\' to.'))));
     // Only show the preview link if the recipient has been saved.
     if (!empty($this->EmailTemplate)) {
         $preview = sprintf('<p><a href="%s" target="_blank" class="ss-ui-button">%s</a></p><em>%s</em>', "admin/pages/edit/EditForm/field/EmailRecipients/item/{$this->ID}/preview", _t('UserDefinedForm.PREVIEW_EMAIL', 'Preview email'), _t('UserDefinedForm.PREVIEW_EMAIL_DESCRIPTION', 'Note: Unsaved changes will not appear in the preview.'));
     } else {
         $preview = sprintf('<em>%s</em>', _t('UserDefinedForm.PREVIEW_EMAIL_UNAVAILABLE', 'You can preview this email once you have saved the Recipient.'));
     }
     // Email templates
     $fields->addFieldsToTab('Root.EmailContent', array(CheckboxField::create('HideFormData', _t('UserDefinedForm.HIDEFORMDATA', 'Hide form data from email?')), CheckboxField::create('SendPlain', _t('UserDefinedForm.SENDPLAIN', 'Send email as plain text? (HTML will be stripped)')), DropdownField::create('EmailTemplate', _t('UserDefinedForm.EMAILTEMPLATE', 'Email template'), $this->getEmailTemplateDropdownValues())->addExtraClass('toggle-html-only'), HTMLEditorField::create('EmailBodyHtml', _t('UserDefinedForm.EMAILBODYHTML', 'Body'))->addExtraClass('toggle-html-only'), TextareaField::create('EmailBody', _t('UserDefinedForm.EMAILBODY', 'Body'))->addExtraClass('toggle-plain-only'), LiteralField::create('EmailPreview', '<div id="EmailPreview" class="field toggle-html-only">' . $preview . '</div>')));
     // Custom rules for sending this field
     $grid = new GridField("CustomRules", _t('EditableFormField.CUSTOMRULES', 'Custom Rules'), $this->CustomRules(), $this->getRulesConfig());
     $grid->setDescription(_t('UserDefinedForm.RulesDescription', 'Emails will only be sent to the recipient if the custom rules are met. If no rules are defined, this receipient will receive notifications for every submission.'));
     $fields->addFieldsToTab('Root.CustomRules', array(new DropdownField('CustomRulesCondition', _t('UserDefinedForm.SENDIF', 'Send condition'), array('Or' => 'Any conditions are true', 'And' => 'All conditions are true')), $grid));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Пример #2
0
 /**
  * getCMSFields
  * Construct the FieldList used in the CMS. To provide a
  * smarter UI we don't use the scaffolding provided by
  * parent::getCMSFields.
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css');
     $customer = $this->Customer();
     $fields = FieldList::create(Tabset::create("Root", Tabset::create("Order", Tab::create("CustomerDetails", HeaderField::create("Customer Selection"), CompositeField::create(DropdownField::create("CustomerID", $this->exists() ? "Customer" : "Select a Customer", Customer::get()->sort(array('Surname' => 'ASC', 'FirstName' => 'ASC'))->map())->setEmptyString("(Select a Customer)")->setRightTitle($this->exists() ? "To change the customer against this order select the new customer above (when editing from the\n\t\t\t\t\t\t\t\t'Store Orders' screen) and click save." : "Which customer is this order for?")), $this->exists() ? HeaderField::create("Customer Details") : null, $this->exists() ? CompositeField::create(ReadonlyField::create("Customer.FirstName", "First Name", $customer->FirstName), ReadonlyField::create("Customer.Surname", "Surname", $customer->Surname), ReadonlyField::create("Customer.CompanyName", "Company", $customer->CompanyName), ReadonlyField::create("Customer.Landline", "Landline Number", $customer->LandlineNumber), ReadonlyField::create("Customer.Mobile", "Mobile Number", $customer->MobileNumber)) : ""), Tab::create("OrderDetails", HeaderField::create("Order Details"), CompositeField::create(DropdownField::create("Status", "Order Status", Order_Statuses::get()->map()), DropdownField::create("BillingAddressID", "Billing Address", DataObject::get("Customer_AddressBook", "(`CustomerID`=" . $this->Customer()->ID . ")")->map())->setRightTitle("Customers' billing address.")->setEmptyString("(Select one)"), DropdownField::create("ShippingAddressID", "Shipping Address", DataObject::get("Customer_AddressBook", "(`CustomerID`=" . $this->Customer()->ID . ")")->map())->setRightTitle("Customers' shipping address.")->setEmptyString("(Select one)")), HeaderField::create("Order Items (Basket)"), CompositeField::create($items = GridField::create("OrderItems", "", $this->Order_Items(), GridFieldConfig_RecordEditor::create()), ReadonlyField::create("SubTotal", "Basket Total (" . Product::getDefaultCurrency() . ")", $this->calculateSubTotal())), HeaderField::create("Shipping"), CompositeField::create(FieldGroup::create(DropdownField::create("Courier", "Courier", $this->getCouriers($this->ID))->setRightTitle("Which courier is being used for this order?")->setEmptyString("(Select one)"), Textfield::create("TrackingNo", "Tracking Number (Optional)")->setRightTitle("If the shipment has a tracking number, enter it here.")), ReadonlyField::create("Shipping", "Shipping Total (" . Product::getDefaultCurrency() . ")", $this->calculateShippingTotal())), HeaderField::create("Order Totals"), CompositeField::create(FieldGroup::create("Tax (" . Product::getDefaultCurrency() . ")", ReadonlyField::create("ProductTaxInclusive", "Product Tax (Inclusive)", $this->calculateProductTax(1))->setRightTitle("Basket total is inclusive of this tax."), ReadonlyField::create("ProductTaxExclusive", "Product Tax (Exclusive)", $this->calculateProductTax(2))->setRightTitle("Basket total is exclusive of this tax."), ReadonlyField::create("ShippingTax", "Shipping Tax", $this->calculateShippingTax($this->calculateShippingTotal()))->setRightTitle(StoreSettings::get_settings()->TaxSettings_ShippingInclusiveExclusive == 1 ? "Shipping price is inclusive of this tax." : "Shipping price is exclusive of this tax.")), FieldGroup::create("Final Totals (" . Product::getDefaultCurrency() . ")", ReadonlyField::create("Total", "Final Total", $this->calculateOrderTotal()), ReadonlyField::create("TotalPayments", "Total Payments", $this->calculatePaymentTotal()), ReadonlyField::create("OutstandingBalance", "Outstanding Balance", $this->calculateRemainingBalance()))), HeaderField::create("Payments"), CompositeField::create($items = GridField::create("OrderPayments", "", $this->Order_Payment(), GridFieldConfig_RecordEditor::create()))), Tab::create("OrderComments", HeaderField::create("Order Comments"), CompositeField::create(ReadonlyField::create("CustomerComments", "Customer Comments")->setRightTitle("These are the comments of this customer."), TextareaField::create("AdminComments", "Admin Comments")->setRightTitle("Only store admins can see these comments"))), Tab::create("OrderEmails", HeaderField::create("Order Emails"), CompositeField::create($items = GridField::create("Order_Emails", "", $this->Order_Emails(), GridFieldConfig_RecordViewer::create()))))));
     //If record doesn't exist yet, hide certain tabs.
     !$this->exists() ? $fields->RemoveFieldsFromTab("Root.Order", array("OrderDetails", "OrderComments", "OrderEmails")) : null;
     /* 
      * If record exists, and order is unpaid show warning message to prevent shipment of unpaid orders.
      * Otherwise show a success message.
      */
     if ($this->exists() && $this->calculateRemainingBalance() > 0) {
         $alert = new LiteralField("OrderPayment_LiteralField", "<div class=\"literal-field field\">\n\t\t\t\t\t<div class=\"message error\">\n\t\t\t\t\t\t<strong>ORDER REMAINS UNPAID</strong> - This order has an outstanding balance of " . Product::getDefaultCurrency() . $this->calculateRemainingBalance() . ". If the customer has paid then the\n\t\t\t\t\t\t payment gateway may not have provided a payment status yet.\n\t\t\t\t\t</div>\n\t\t\t\t</div>");
         $fields->addFieldToTab("Root.Order", $alert, "Status");
     } elseif ($this->exists() && $this->calculateRemainingBalance() == 0) {
         $alert = new LiteralField("OrderPayment_LiteralField", "<div class=\"literal-field field\">\n\t\t\t\t\t<div class=\"message good\">\n\t\t\t\t\t\t<strong>BALANCE PAID</strong> - This balance of this order has been paid. You may now prepare and \n\t\t\t\t\t\tdispatch the order items below.\n\t\t\t\t\t</div> \n\t\t\t\t</div>");
         $fields->addFieldToTab("Root.Order", $alert, "Status");
     }
     return $fields;
 }
 /**
  * Constructs a FieldList for use in the CMSForm.
  *
  * @return FieldList
  */
 public function construct_cms_fields()
 {
     //Create the FieldList and push the Root TabSet on to it.
     $fields = FieldList::create($root = TabSet::create('Root', Tabset::create("Orders", Tab::create($title = "All Orders", HeaderField::create($title), CompositeField::create(GridField::create("AllOrders", "", DataObject::get("Order", "(`TempBasketID` IS NULL) AND (`Status`!='1')", "Created DESC"), GridFieldConfig_RecordEditor::create()))), Tab::create($title = "Pending", LiteralField::create("Pending_LiteralField", "<div class=\"literal-field literal-field-noborder\">\n\t\t\t\t\t\t\t\t<div class=\"message warning\">\n\t\t\t\t\t\t\t\t\t<strong>THESE ORDERS ARE UNPAID:</strong><br />\n\t\t\t\t\t\t\t\t\tThese orders have been placed but their associated payment gateway is yet to respond\n\t\t\t\t\t\t\t\t\twith a payment status. Do not process / dispatch these orders until they are\n\t\t\t\t\t\t\t\t\tmoved to another status.\n\t\t\t\t\t\t\t\t</div>\t\t\n\t\t\t\t\t\t\t</div>"), HeaderField::create($title . " Orders"), CompositeField::create(GridField::create("PendingOrders", "", DataObject::get("Order", "(`TempBasketID` IS NULL) AND (`Status`='1')", "Created DESC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")))), Tab::create($title = "Processing", HeaderField::create($title . " Orders"), CompositeField::create(GridField::create("ProcessingOrders", "", DataObject::get("Order", "(`TempBasketID` IS NULL) AND (`Status`='2')", "Created DESC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")))), Tab::create($title = "Awaiting Stock", HeaderField::create($title), CompositeField::create(GridField::create("AwaitingStockOrders", "", DataObject::get("Order", "(`TempBasketID` IS NULL) AND (`Status`='3')", "Created DESC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")))), Tab::create($title = "Completed", HeaderField::create($title), CompositeField::create(GridField::create("CompletedOrders", "", DataObject::get("Order", "(`TempBasketID` IS NULL) AND (`Status`='4')", "Created DESC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")))), Tab::create($title = "Shipped", HeaderField::create($title . " Orders"), CompositeField::create(GridField::create("ShippedOrders", "", DataObject::get("Order", "(`TempBasketID` IS NULL) AND (`Status`='5')", "Created DESC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")))), Tab::create($title = "Refunded", HeaderField::create($title . " Orders"), CompositeField::create(GridField::create("RefundedOrders", "", DataObject::get("Order", "(`TempBasketID` IS NULL) AND (`Status`='6')", "Created DESC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")))), Tab::create($title = "Part Refunded", HeaderField::create($title . " Orders"), CompositeField::create(GridField::create("PartRefundedOrders", "", DataObject::get("Order", "(`TempBasketID` IS NULL) AND (`Status`='7')", "Created DESC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")))), Tab::create($title = "Cancelled", HeaderField::create($title . " Orders"), CompositeField::create(GridField::create("CancelledOrders", "", DataObject::get("Order", "(`TempBasketID` IS NULL) AND (`Status`='8')", "Created DESC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")))), Tab::create($title = "Other Statuses", HeaderField::create("Other Status"), CompositeField::create(LiteralField::create($title = "CustomFieldsDescription", "<div class=\"literal-field literal-field-noborder\">\n\t\t\t\t\t\t\t\t\tThis table displays all orders with a custom order statuses as set in Store Settings.\n\t\t\t\t\t\t\t\t</div>"), GridField::create("CustomStatusOrders", "", DataObject::get("Order", "(`Status`>'8')", "Created DESC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")))))), HiddenField::create('ID', false, 0));
     //Tab nav in CMS is rendered through separate template
     $root->setTemplate('CMSTabSet');
     return $fields;
 }
 /**
  * Constructs a FieldList for use in the CMSForm.
  *
  * @return FieldList
  */
 public function construct_cms_fields()
 {
     //Create the FieldList and push the Root TabSet on to it.
     $fields = FieldList::create($root = TabSet::create('Root', Tabset::create("Settings", Tabset::create("General", Tab::create("StoreSettings", HeaderField::create("Maintenance Mode"), CompositeField::create(DropdownField::create("StoreSettings_StoreAvailable", "Store Status", array("1" => "Live", "2" => "Down for Maintenance (show the below message)")), TextareaField::create("StoreSettings_StoreAvailableMessage", "Maintenance Message")->setRightTitle("The message to display to visitors whilst your store is in maintenance mode.")), HeaderField::create("Store Details"), CompositeField::create(TextField::create("StoreSettings_StoreName", "Store Name")->setRightTitle("i.e. Steve's Shoe Shop."), TextareaField::create("StoreSettings_StoreAddress", "Store Address")->setRightTitle("<strong>Example</strong><br />123 ACME Drive<br />Enfield<br />London</br />EN1 1YQ"), CountryDropdownField::create("StoreSettings_StoreCountry", "Store Country")), HeaderField::create("Product Measurements"), CompositeField::create(DropdownField::create("StoreSettings_ProductWeight", "Product Weight", array("Pounds" => "Pounds", "Ounces" => "Ounces", "Grams" => "Grams", "Kilograms" => "Kilograms", "Tonns" => "Tonns"))->setRightTitle("Select the weight measurement you wish to use in your store."), DropdownField::create("StoreSettings_ProductDimensions", "Product Dimensions", array("Inches" => "Inches", "Millimetres" => "Millimetres", "Centimetres" => "Centimetres"))->setRightTitle("Select the width, height and length measurement you wish to use in your store.")), HeaderField::create("SSL"), CompositeField::create(LiteralField::create("SSL_LiteralField", "<div class=\"literal-field literal-field-noborder\">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message warning\">\n\t\t\t\t\t\t\t\t\t\t\t<strong>IMPORTANT:</strong><br />\n\t\t\t\t\t\t\t\t\t\t\tIn order to protect your customers personally identifiable information it is\n\t\t\t\t\t\t\t\t\t\t\tstrongly recommended that you consider installing an SSL certificate for your website.\n\t\t\t\t\t\t\t\t\t\t\t<br />If you are unsure on how to do this please reach out to the party responsible\n\t\t\t\t\t\t\t\t\t\t\tfor this website. \n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tEnabling the option below will ensure all communications between third-party providers\n\t\t\t\t\t\t\t\t\t\tare transmitted over the https:// protocol.\n\t\t\t\t\t\t\t\t\t</div>"), CheckboxField::create("StoreSettings_SSLToggle", "Yes, I have SSL enabled."))), Tab::create("DisplaySettings", HeaderField::create("General Display Settings"), CompositeField::create(NumericField::create("DisplaySettings_FeaturedProducts", "Featured Products")->setRightTitle("Enter the number of products you wish to display in the Featured Products panels."), NumericField::create("DisplaySettings_NewProducts", "New Products")->setRightTitle("Enter the number of products you wish to display in the New Products panels."), DropdownField::create("DisplaySettings_CartQuantity", "Cart Quantity Selection", array("1" => "Dropdown", "2" => "Textbox"))->setRightTitle("Select how you wish the quantity selector to be shown on the product pages.")), HeaderField::create("Product Display Settings"), CompositeField::create(CheckboxField::create("DisplaySettings_ShowPrice", "Show product prices im my store."), CheckboxField::create("DisplaySettings_ShowSKU", "Show product SKUs in my store."), CheckboxField::create("DisplaySettings_ShowWeight", "Show product weights in my store."), CheckboxField::create("DisplaySettings_ShowDimensions", "Show product dimensions in my store."), DropdownField::create("DisplaySettings_ProductSort", "Default Product Sort", array("Title ASC" => "Product Name Ascending", "Title DESC" => "Product Name Descending", "SalePrice ASC, RegularPrice ASC" => "Price Lowest to Highest", "SalePrice DESC, RegularPrice DESC" => "Price Highest to Lowest", "Created ASC" => "Oldest First", "Created DESC" => "Newest First"))), HeaderField::create("Product Photo Display Settings"), CompositeField::create(LiteralField::create("ProductPagePhoto_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\t<strong>Product Page Photo Size</strong><br />\n\t\t\t\t\t\t\t\t\t\tEnter the width and height to use for the main photo on a product page.\n\t\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("DisplaySettings_ProductPagePhotoWidth", "Width (pixels)"), NumericField::create("DisplaySettings_ProductPagePhotoHeight", "Width (pixels)")), LiteralField::create("ProductThumbnailPhoto_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\t<strong>Product Thumbnail Photo Size</strong><br />\n\t\t\t\t\t\t\t\t\t\tEnter the width and height to use for product thumbnails throughout the store.\n\t\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("DisplaySettings_ProductThumbnailPhotoWidth", "Width (pixels)"), NumericField::create("DisplaySettings_ProductThumbnailPhotoHeight", "Height (pixels)")), LiteralField::create("ProductEnlargedPhoto_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\t<strong>Enlarged Photo Size</strong><br />\n\t\t\t\t\t\t\t\t\t\tEnter the width and height to use for enlarged photos. Users will see this if they click\n\t\t\t\t\t\t\t\t\t\tto see the larger version of a product photo from a product page.\n\t\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("DisplaySettings_ProductEnlargedPhotoWidth", "Width (pixels)"), NumericField::create("DisplaySettings_ProductEnlargedPhotoHeight", "Height (pixels)"))))), Tabset::create("Orders", Tab::create("CheckoutSettings", HeaderField::create("Initial Order Status"), CompositeField::create(DropdownField::create("CheckoutSettings_InitialStatus", "Status", DataObject::get("Order_Statuses", "", "Title ASC")->map('ID', 'Title'))->setRightTitle("Select the status you wish all new orders to be set to.")), HeaderField::create("Guest Checkout"), CompositeField::create(CheckboxField::create("CheckoutSettings_GuestCheckout", "Allow customers to checkout as a guest without the need for an account."), CheckboxField::create("CheckoutSettings_GuestCheckoutAccount", "Create an account for customers if they checkout as a guest (if they do not already have one)")), HeaderField::create("Order Comments"), CompositeField::create(CheckboxField::create("CheckoutSettings_OrderComments", "Allow customers to provide a comment with their orders.")), HeaderField::create("Terms &amp; Conditions"), CompositeField::create(CheckboxField::create("CheckoutSettings_TermsAndConditions", "I require my customers to have agreed to terms and conditions before they can place an order."), TreeDropdownField::create("CheckoutSettings_TermsAndConditionsSiteTree", "Terms &amp; Conditions Page", "SiteTree"))), Tab::create("Order Statuses", HeaderField::create("Custom Order Statuses"), CompositeField::create(LiteralField::create("CustomOrderStatus_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThis section allows you to specify custom order statuses where those out of the box\n\t\t\t\t\t\t\t\t\t\tdo not otherwise match your businesses requirements.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("CustomOrderStatus", "", DataObject::get("Order_Statuses", "(0=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Default Order Statuses"), CompositeField::create(LiteralField::create("DefaultOrderStatus_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThis section displays the default order statuses that are used throughout the store. Feel free\n\t\t\t\t\t\t\t\t\t\tto alter their Display Name and Descriptions to suit the needs of your business.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("DefaultOrderStatus", "", DataObject::get("Order_Statuses", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("EmailNotifications", HeaderField::create("Send store emails from"), CompositeField::create(EmailField::create("EmailNotification_SendEmailsFrom", "From Email Address")->setRightTitle("\n\t\t\t\t\t\t\t\t\tThis is the address that is used in the 'From' section of all automatically generated emails.<br />\n\t\t\t\t\t\t\t\t\t<strong>SMTP Users:</strong> If you are using a SilverStripe SMTP module it is strongly recommended\n\t\t\t\t\t\t\t\t\tyou set this value to that of the authenticated SMTP email address.")), HeaderField::create("New order notifications"), CompositeField::create(EmailField::create("EmailNotification_AdminNewOrder", "Admin Notification Email")->setRightTitle("When the store receives a new order send a notification to the above address.")), HeaderField::create("Send the customer an email when"), CompositeField::create(CheckboxField::create("EmailNotification_AccountCreated", "They create an account."), CheckboxField::create("EmailNotification_OrderPlaced", "They place an order with my store.")), HeaderField::create("Send the customer an email when their order status changes to"), CompositeField::create(CheckboxSetField::create("EmailNotification_OrderStatuses", "Pick your desired statuses", DataObject::get("Order_Statuses", "", "Title ASC")->map('ID', 'Title'))))), Tab::create("Stock", HeaderField::create("Stock Management"), CompositeField::create(LiteralField::create("StockManagement_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t<strong>What is Stock Management?</strong><br />\n\t\t\t\t\t\t\t\t\tStock management is designed to keep tabs on your stock levels. If enabled, stock levels will be\n\t\t\t\t\t\t\t\t\tmanaged by the store and automatically decremented upon receiving a successful order.<br />\n\t\t\t\t\t\t\t\t\tIt will also prevent customers from placing an order for a product if it is deemed to\n\t\t\t\t\t\t\t\t\tbe out of stock.\n\t\t\t\t\t\t\t\t</div>"), CheckboxField::create("Stock_StockManagement", "Enable stock control in my store.")), HeaderField::create("Pending Orders"), CompositeField::create(LiteralField::create("PendingOrders_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tEnter the number of minutes that stock allocated to unpaid orders will be held before the \n\t\t\t\t\t\t\t\t\tassociated order is cancelled and held stock is made available to other customers.\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</div>"), FieldGroup::create(NumericField::create("Stock_PendingOrdersFreezeStock", ""))), HeaderField::create("Stock Levels"), CompositeField::create(FieldGroup::create(NumericField::create("Stock_LowStockThreshold", "Low Stock Threshold")->setRightTitle("The stock level considered as low."), NumericField::create("Stock_OutOfStockThreshold", "Out of Stock Threshold")->setRightTitle("The stock level considered as out of stock."), TextField::create("Stock_OutofStockMessage", "Out of Stock Message")->setRightTitle("The message to display when a product is out of stock.")), DropdownField::create("Stock_ProductOutOfStock", "Product Out of Stock", array("1" => "Completely hide the product from my store", "2" => "Hide the product but allow the product page to be accessed from its URL", "3" => "Do not make any changes"))->setRightTitle("Select what you wish to happen when a product is out of stock."), DropdownField::create("Stock_StockLevelDisplay", "Stock Level Display", array("1" => "Always show stock levels", "2" => "Show stock levels after the product drops below the low stock threshold", "3" => "Never show stock levels"))->setRightTitle("Select how you would like stock levels to appear in your store."))), Tab::create("Couriers", HeaderField::create("Couriers"), CompositeField::create(GridField::create("CourierSettings", "", DataObject::get("Courier", "", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("Gateways", HeaderField::create("Gateways"), CompositeField::create(GridField::create("GatewaySettings", "", DataObject::get("Gateway", "", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("Currency", HeaderField::create("Accepted Currencies"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\tYou can define additional currencies in this section. Customers will be shown prices in their\n\t\t\t\t\t\t\t\t\tselected currency throughout the store but will transact in your local currency.\n\t\t\t\t\t\t\t\t</div>"), GridField::create("CurrencySettings_AcceptedCurrencies", "", DataObject::get("StoreCurrency", "(0=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Local (Default) Currency"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\tConfigure your store's local (default) currency in this section.\n\t\t\t\t\t\t\t\t</div>"), GridField::create("CurrencySettings_LocalCurrency", "", DataObject::get("StoreCurrency", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tabset::create("Tax", Tab::create("TaxSettings", HeaderField::create("Tax Settings"), CompositeField::create(DropdownField::create("TaxSettings_InclusiveExclusive", "Product Prices Are", array("1" => "Inclusive of Tax", "2" => "Exclusive of Tax")), DropdownField::create("TaxSettings_ShippingInclusiveExclusive", "Shipping Prices Are", array("1" => "Inclusive of Tax", "2" => "Exclusive of Tax")), DropdownField::create("TaxSettings_CalculateUsing", "Calculate Tax Using", array("1" => "Billing Address", "2" => "Shipping Address", "3" => "Store Address")))), Tab::create("TaxClasses", HeaderField::create("Other Tax Classes"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tA Tax class allows you to define tax categories.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_ClassesOther", "", DataObject::get("TaxClasses", "(0=SystemCreated)", "ID ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Default Tax Classes"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThese are the default tax classes.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_ClassesDefault", "", DataObject::get("TaxClasses", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction")))), Tab::create("TaxZones", HeaderField::create("Other Tax Zones"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tA Tax Zone allows you to define Tax rules on a country by country basis.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_Zones", "", DataObject::get("TaxZones", "(0=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create())), HeaderField::create("Default Tax Zone"), CompositeField::create(LiteralField::create("CurrencySettings_LiteralField", "<div class=\"literal-field\">\n\t\t\t\t\t\t\t\t\t\tThis is the default tax zone applies where no zone exists for a customers' country.\n\t\t\t\t\t\t\t\t\t</div>"), GridField::create("TaxSettings_ZonesDefault", "", DataObject::get("TaxZones", "(1=SystemCreated)", "Title ASC"), GridFieldConfig_RecordEditor::create()->removeComponentsByType("GridFieldAddNewButton")->removeComponentsByType("GridFieldDeleteAction"))))), Tab::create("Reviews", HeaderField::create("Product Reviews"), CompositeField::create(CheckboxField::create("ProductReviewSettings_EnableReviews", "Enable product reviews in my store."), CheckboxField::create("ProductReviewSettings_ApprovedPurchaserOnly", "Require a customer to have purchased an item before making a review."), CheckboxField::create("ProductReviewSettings_AdminApproval", "Require admin approval before reviews are made visible."))))), HiddenField::create('ID', false, 0));
     //Tab nav in CMS is rendered through separate template
     $root->setTemplate('CMSTabSet');
     return $fields;
 }
 /**
  * getCMSFields
  * Construct the FieldList used in the CMS. To provide a
  * smarter UI we don't use the scaffolding provided by
  * parent::getCMSFields.
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css');
     //Create the FieldList and push the Root TabSet on to it.
     $fields = FieldList::create($root = TabSet::create('Root', Tabset::create("Product", Tab::create("Details", HeaderField::create("General"), CompositeField::create(TextField::create("Title", "Product Name"), NumericField::create("RegularPrice", "Regular Price (" . $this->getDefaultCurrency() . ")")->setRightTitle("The standard price for this product in your store."), FieldGroup::create("Other Prices (" . $this->getDefaultCurrency() . ")", NumericField::create("SalePrice", "Sale Price (optional)")->setRightTitle("If entered, this price will replace the regular price."), NumericField::create("RetailPrice", "Recommended Retail Price (optional)")->setRightTitle("If entered, the retail price will be indicated on your site."), NumericField::create("CostPrice", "Cost Price (optional)")->setRightTitle("Not displayed on your site. For your reference only."))), HeaderField::create("Photos (optional)"), CompositeField::create($this->exists() ? UploadField::create("Images", "Product Photos")->setAllowedFileCategories('image')->setAllowedMaxFileNumber(4)->setFolderName('product-photos') : LiteralField::create($title = "Product Photos", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<label class=\"left\">" . $title . "</label>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"middleColumn\">\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\t\t\t\t\tYou will be able to add photos to this product after clicking create.\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t</div>")), HeaderField::create("Product Description (optional)"), CompositeField::create(HtmlEditorField::create("Description", ""))->addExtraClass("TorindulCompositeField TorindulCompositeField_16Margin"), HeaderField::create("Stock Levels")->addExtraClass("TorindulHeaderField TorindulCompositeField_16Margin"), CompositeField::create(NumericField::create("StockLevel", "Current Stock Level")->setRightTitle("Total quantity currently in stock.")), HeaderField::create("Availability"), CompositeField::create(DropdownField::create("EnablePurchases", "Enable Purchase?", array("1" => "Yes, allow customers to purchase this product.", "0" => "No, do not allow customers to purchase this product.")), DropdownField::create("Visible", "Visible to Customers?", array("1" => "Yes, allow my customers to see this product in my store.", "0" => "No, hide this product from customers."))), HeaderField::create("Miscellaneous"), CompositeField::create(DB::query("SELECT COUNT(*) FROM Product_Brands")->value() < 1 ? LiteralField::create($title = "Brand (optional)", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<label class=\"left\">" . $title . "</label>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<div class=\"middleColumn\">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\t\t\t\t\tBefore you can select a product brand you must first create one. \n\t\t\t\t\t\t\t\t\t\t\tPlease return to the previous screen and review the brands tab.\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</div>")->setRightTitle($title) : DropdownField::create("Brand", "Brand (optional)", DataObject::get("Product_Brands", "", "Title ASC")->map("ID", "Title"))->setEmptyString('(Select one)')->setRightTitle("Specify this products brand, if applicable."), DB::query("SELECT COUNT(*) FROM Product_Categories")->value() < 1 ? LiteralField::create($title = "Categories (optional)", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<label class=\"left\">" . $title . "</label>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<div class=\"middleColumn\">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\t\t\t\t\tBefore you can select one or more product categories you must first create them. \n\t\t\t\t\t\t\t\t\t\t\tPlease return to the previous screen and review the categories tab.\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</div>")->setRightTitle($title) : CheckboxSetField::create("Categories", "Categories (optional)", DataObject::get("Product_Categories", "", "Title ASC")->map("ID", "Title")), DropdownField::create("TaxClass", "Tax Class", DataObject::get("TaxClasses", "", "Title ASC")->map("ID", "Title")), TextField::create("SKU", "SKU/Product Code (optional)"), OptionsetField::create("Featured", "Featued Product", array("0" => "No", "1" => "Yes"))->setRightTitle("When set to yes this product will appear as a 'Featured Product' in your storefront."), FieldGroup::create($title = "Measurements", TextField::create("Width", "Width (optional)")->setRightTitle("in " . self::get_settings()->StoreSettings_ProductDimensions), TextField::create("Height", "Height (optional)")->setRightTitle("in " . self::get_settings()->StoreSettings_ProductDimensions), TextField::create("Length", "Length (optional)")->setRightTitle("in " . self::get_settings()->StoreSettings_ProductDimensions), TextField::create("Weight", "Weight (optional)")->setRightTitle("in " . self::get_settings()->StoreSettings_ProductWeight)))), Tab::create("CustomFields", HeaderField::create("Custom Fields"), CompositeField::create(LiteralField::create($title = "CustomFieldsDescription", "<div class=\"literal-field literal-field-noborder\">\n\t\t\t\t\t\t\t\t\tCustom fields allow you to specify additional information that will appear on the product's page,\n\t\t\t\t\t\t\t\t\tsuch as a book's ISBN or a DVD's release date.\n\t\t\t\t\t\t\t\t</div>"), $this->exists() ? GridField::create("CustomFields", "", $this->ProductCustomFields()->sort("Title ASC"), GridFieldConfig_RecordEditor::create()) : LiteralField::create($title = "CustomFieldsNotice", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\t\t\t\tYou will be able to add custom fields to this product after clicking create.\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</div>")->setRightTitle($title))), Tab::create("Reviews", HeaderField::create("Product Reviews"), CompositeField::create(LiteralField::create($title = "CustomFieldsDescription", "<div class=\"literal-field literal-field-noborder\">\n\t\t\t\t\t\t\t\t\t\tAccording to Reevoo, reviews produce an average 18% uplift in sales and 50 or more reviews per \n\t\t\t\t\t\t\t\t\t\tproduct can mean a 4.6% increase in conversion rates.\n\t\t\t\t\t\t\t\t\t</div>"), $this->checkReviewsEnabled() ? $this->exists() ? GridField::create("ProductReviews", "", $this->ProductReviews()->sort("Date DESC")) : LiteralField::create($title = "CustomFieldsNotice", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message notice\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-info-circle\"></i>\n\t\t\t\t\t\t\t\t\t\t\tYou will be able to manage reviews for this product after clicking create.\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t</div>")->setRightTitle($title) : LiteralField::create($title = "ReviewsNotice", "<div class=\"literal-field field\">\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<div class=\"message warning\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-exclamation-circle\"></i>\n\t\t\t\t\t\t\t\t\t\t\tProduct reviews are currently disabled for your store. You can enable them in store settings.\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t</div>")->setRightTitle($title))))));
     return $fields;
 }