public function getResult($queryRow) { $dr = DiscountRule::getByID($queryRow['drID']); if ($dr) { $dr->retrieveStatistics(); } return $dr; }
public function delete() { if ($this->isPost()) { $data = $this->post(); $dr = DiscountRule::getByID($data['drID']); if ($dr) { $dr->remove(); } $this->redirect('/dashboard/store/discounts/', 'deleted'); } $this->redirect('/dashboard/store/discounts/'); }
public function save($data) { $db = Database::get(); if ($data['drID']) { //if we know the drID, we're updating. if ($data['validFrom'] == '0') { $data['drValidFrom_dt'] = null; } if ($data['validTo'] == '0') { $data['drValidTo_dt'] = null; } //update discount details $vals = array($data['drName'], $data['drDisplay'], $data['drEnabled'], $data['drDescription'], $data['drDeductType'], $data['drValue'], $data['drPercentage'], $data['drDeductFrom'], $data['drTrigger'], $data['drSingleUseCodes'], $data['drExclusive'], $data['drCurrency'], $data['drValidFrom_dt'], $data['drValidTo_dt'], $data['drID']); $drID = $data['drID']; $db->Execute('UPDATE VividStoreDiscountRules SET drName=?, drDisplay=?, drEnabled=?, drDescription=?, drDeductType=?, drValue=?, drPercentage=?, drDeductFrom=?, drTrigger=?, drSingleUseCodes=?, drExclusive=?, drCurrency=?, drValidFrom=?, drValidTo=? WHERE drID = ?', $vals); } else { //else, we don't know it, so we're adding $dt = Core::make('helper/date'); $now = $dt->getLocalDateTime(); //add discount details $vals = array($data['drName'], $data['drDisplay'], $data['drEnabled'], $data['drDescription'], $data['drDeductType'], $data['drValue'], $data['drPercentage'], $data['drDeductFrom'], $data['drTrigger'], $data['drSingleUseCodes'], $data['drExclusive'], $data['drExclusive'], $data['drCurrency'], $data['drValidFrom_dt'], $data['drValidTo_dt'], $now); $db->Execute("INSERT INTO VividStoreDiscountRules (\n drName,\n drDisplay,\n drEnabled,\n drDescription,\n drDeductType,\n drValue,\n drPercentage,\n drDeductFrom,\n drTrigger,\n drSingleUseCodes,\n drExclusive,\n drCurrency,\n drValidFrom,\n drValidTo,\n drDateAdded) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", $vals); $drID = $db->lastInsertId(); } $discountRule = DiscountRule::getByID($drID); return $discountRule; }