public function form_content() { $ret = '<form method="get"> <div class="col-sm-5"> <label>Coupon</label> <select name="coupon_id" class="form-control">'; $dbc = $this->connection; $dbc->selectDB($this->config->get('OP_DB')); $hc = new HouseCouponsModel($dbc); foreach ($hc->find() as $obj) { if ($obj->description() == '') { continue; } $ret .= sprintf('<option value="%s">%s</option>', $obj->coupID(), $obj->description()); } $ret .= '</select> <p> <button type="submit" class="btn btn-default">Submit</button> </p> </div>'; $ret .= FormLib::standardDateFields(); $ret .= '</form>'; return $ret; }
private function couponItemTable($id) { $dbc = FannieDB::get($this->config->get('OP_DB')); $hc = new HouseCouponsModel($dbc); $hc->coupID($id); $hc->load(); $query = ' SELECT h.upc, COALESCE(p.description, \'Unknown item\') AS description, h.type FROM houseCouponItems AS h ' . DTrans::joinProducts('h') . ' WHERE h.coupID=?'; if ($hc->minType() == 'MX') { $query = "\n SELECT h.upc,\n CASE WHEN h.type='QUALIFIER' THEN d.dept_name ELSE p.description END as description,\n h.type\n FROM houseCouponItems AS h\n LEFT JOIN products AS p ON p.upc=h.upc AND h.type='DISCOUNT'\n LEFT JOIN departments AS d ON h.upc=d.dept_no AND h.type='QUALIFIER'\n WHERE h.coupID=?"; } elseif ($hc->minType() == "D" || $hc->minType() == "D+" || $hc->minType() == 'C' || $hc->minType() == 'C+' || $hc->discountType() == '%D') { $query = ' SELECT h.upc, COALESCE(d.dept_name, \'Unknown department\') AS description, h.type FROM houseCouponItems AS h LEFT JOIN departments AS d ON d.dept_no=h.upc WHERE h.coupID=?'; } $prep = $dbc->prepare($query); $result = $dbc->execute($prep, array($id)); $ret = ''; while ($w = $dbc->fetch_row($result)) { $ret .= sprintf('<tr> <td>%s</td> <td>%s</td> <td>%s</td> <td><input type="checkbox" name="del[]" value="%s" /></td> </tr>', $w['upc'], $w['description'], $w['type'], $w['upc']); } return $ret; }