/**
  * Renders the Sell Price Formula Dropdown
  * @param Redbean $model
  * @param Object $form
  * @param string $inputNameIdPrefix
  * @param string $attribute
  * @return string
  */
 protected function renderNameDropDown($model, $form, $inputNameIdPrefix, $attribute)
 {
     $id = $this->getEditableInputId($inputNameIdPrefix, $attribute);
     $discountOrMarkupPercentageTextFieldId = $this->getEditableInputId($inputNameIdPrefix, 'discountOrMarkupPercentage');
     $sellPriceValueId = $this->getEditableInputId('sellPrice', 'value');
     $htmlOptions = array('name' => $this->getEditableInputName($this->attribute, 'type'), 'id' => $id, 'onchange' => 'showHideDiscountOrMarkupPercentageTextField($(this).val(), \'' . $discountOrMarkupPercentageTextFieldId . '\');
                           enableDisableSellPriceElementBySellPriceFormula($(this).val(), \'' . $sellPriceValueId . '\', "sellPrice");
                           calculateSellPriceBySellPriceFormula()');
     $dropDownField = $form->dropDownList($model, $attribute, SellPriceFormula::getTypeDropDownArray(), $htmlOptions);
     $error = $form->error($model, $attribute, array('inputID' => $id));
     return $dropDownField . $error;
 }
 /**
  * Resolve sell price formula data to be exported
  * @param array $data
  */
 public function resolveData(&$data)
 {
     assert('$this->model->{$this->attribute} instanceof SellPriceFormula');
     $sellPriceFormulaModel = $this->model->{$this->attribute};
     $type = $sellPriceFormulaModel->type;
     $discountOrMarkupPercentage = $sellPriceFormulaModel->discountOrMarkupPercentage;
     $displayedSellPriceFormulaList = SellPriceFormula::getDisplayedSellPriceFormulaArray();
     $value = '';
     if ($type != null) {
         $value = $displayedSellPriceFormulaList[$type];
         if ($type != SellPriceFormula::TYPE_EDITABLE) {
             $value = str_replace('{discount}', $discountOrMarkupPercentage / 100, $value);
         }
     }
     $data[$this->model->getAttributeLabel($this->attribute)] = $value;
 }
 /**
  * @return array
  */
 protected function getDropDownArray()
 {
     return SellPriceFormula::getTypeDropDownArray();
 }
 /**
  * Get the value of sell price formula displayed in grid view for product template
  * @param RedBeanModel $data
  * @param int $row
  * @return string
  */
 public static function getSellPriceFormulaDisplayedGridValue($data, $row)
 {
     $sellPriceFormulaModel = $data->sellPriceFormula;
     $type = $sellPriceFormulaModel->type;
     $discountOrMarkupPercentage = $sellPriceFormulaModel->discountOrMarkupPercentage;
     $displayedSellPriceFormulaList = SellPriceFormula::getDisplayedSellPriceFormulaArray();
     $content = '';
     if ($type != null) {
         $content = $displayedSellPriceFormulaList[$type];
         if ($type != SellPriceFormula::TYPE_EDITABLE) {
             $content = str_replace('{discount}', $discountOrMarkupPercentage / 100, $content);
         }
     }
     return $content;
 }
 /**
  * Get sell price formula type displayed value
  * @param RedBeanModel $data
  * @param string $attribute
  * @return string
  */
 public static function getSellPriceFormulaType($data, $attribute)
 {
     $dataArray = SellPriceFormula::getTypeDropDownArray();
     return $dataArray[$data->getModel($attribute)->sellPriceFormula->type];
 }
 public function __construct($modelClassName, $attributeName)
 {
     parent::__construct($modelClassName, $attributeName);
     $this->dropDownValues = SellPriceFormula::getTypeDropDownArray();
 }