public function preview_content() { $model = new PriceRuleTypesModel($this->connection); $ret = '<p><div class="form-inline"> <label>Rule type</label> <select name="ruleType" class="form-control"> ' . $model->toOptions() . ' </select> <label>Review Date</label> <input type="text" class="form-control date-field" name="reviewDate" required /> <label><input type="checkbox" name="rm_cds" /> Remove check digits</label> </div></p> '; return $ret; }
public function get_view() { $model = new PriceRuleTypesModel($this->connection); $ret = '<form method="get"> <div class="form-group"> <label>Rule Type</label> <select class="form-control" name="id"> ' . $model->toOptions() . ' </select> </div> <div class="form-group"> <label>Review Date</label> <input type="text" class="form-control date-field" name="date" placeholder="Optional; omit for all items with the given rule type" /> </div> <div class="form-group"> <button type="submit" class="btn btn-default">Create Batch</button> </div> </form>'; return $ret; }
public function showEditForm($upc, $display_mode = 1, $expand_mode = 1) { $db = $this->db(); $product = new ProductsModel($db); $product->upc($upc); if (!$product->load()) { /** Lookup vendor cost on new items */ $vendor = new VendorItemsModel($db); $vendor->upc($upc); foreach ($vendor->find('vendorID') as $v) { $product->cost($v->cost()); break; } } $ret = '<div id="ItemMarginFieldset" class="panel panel-default">'; $ret .= "<div class=\"panel-heading\">\n <a href=\"\" onclick=\"\$('#ItemMarginContents').toggle();return false;\">\n Margin\n </a></div>"; $css = $expand_mode == 1 ? '' : ' collapse'; $ret .= '<div id="ItemMarginContents" class="panel-body' . $css . '">'; $ret .= '<div class="col-sm-5">'; $ret .= '<div id="ItemMarginMeter">'; $ret .= $this->calculateMargin($product->normal_price(), $product->cost(), $product->department(), $upc); $ret .= '</div>'; $ret .= '</div>'; $ret .= '<div class="col-sm-6">'; $ret .= '<div class="form-group form-inline"> <label>Pricing Rule</label> <select name="price-rule-id" class="form-control input-sm" onchange="if(this.value>=0)$(\'#custom-pricing-fields :input\').prop(\'disabled\', true); else $(\'#custom-pricing-fields :input\').prop(\'disabled\', false);"> <option value="0" ' . ($product->price_rule_id() == 0 ? 'selected' : '') . '>Normal</option> <option value="1" ' . ($product->price_rule_id() == 1 ? 'selected' : '') . '>Variable</option> <option value="-1" ' . ($product->price_rule_id() > 1 ? 'selected' : '') . '>Custom</option> </select> <input type="hidden" name="current-price-rule-id" value="' . $product->price_rule_id() . '" /> <label>Avg. Daily Movement</label> ' . sprintf('%.2f', $this->avgSales($upc)) . ' </div>'; $rule = new PriceRulesModel($db); if ($product->price_rule_id() > 1) { $rule->priceRuleID($product->price_rule_id()); $rule->load(); } $disabled = $product->price_rule_id() <= 1 ? 'disabled' : ''; $ret .= '<div id="custom-pricing-fields" class="form-group form-inline"> <label>Custom</label> <select ' . $disabled . ' name="price-rule-type" class="form-control input-sm"> {{RULE_TYPES}} </select> <input type="text" class="form-control date-field input-sm" name="rule-review-date" ' . $disabled . ' placeholder="Review Date" title="Review Date" value="{{REVIEW_DATE}}" /> <input type="text" class="form-control input-sm" name="rule-details" ' . $disabled . ' placeholder="Details" title="Details" value="{{RULE_DETAILS}}" /> </div>'; $types = new PriceRuleTypesModel($db); $ret = str_replace('{{RULE_TYPES}}', $types->toOptions($rule->priceRuleTypeID()), $ret); $ret = str_replace('{{REVIEW_DATE}}', $rule->reviewDate(), $ret); $ret = str_replace('{{RULE_DETAILS}}', $rule->details(), $ret); $ret .= '</div>'; $ret .= '</div>'; $ret .= '</div>'; return $ret; }