setMainTable('coupons'); } /** * Retrieve the detail record for the current $id if the data has not already been loaded. * */ function getCoupon($id = 0){ return $this->getData($id); } /** * Bind the post data to the coupon table and save it * * @return mixed False if the save was unsuccessful, the coupon ID otherwise. */ function store(&$data) { if(!vmAccess::manager('coupon.edit')){ vmWarn('Insufficient permission to store coupons'); return false; } else if( empty($data['virtuemart_coupon_id']) and !vmAccess::manager('coupon.create')){ vmWarn('Insufficient permission to create coupons'); return false; } $table = $this->getTable('coupons'); // Convert selected dates to MySQL format for storing. if ($data['coupon_start_date']) { $startDate = vFactory::getDate($data['coupon_start_date']); $data['coupon_start_date'] = $startDate->toSQL(); } if ($data['coupon_expiry_date']) { $expireDate = vFactory::getDate($data['coupon_expiry_date']); $data['coupon_expiry_date'] = $expireDate->toSQL(); } $table->bindChecknStore($data); $data['virtuemart_coupon_id'] = $table->virtuemart_coupon_id; return $table->virtuemart_coupon_id; } /** * Retireve a list of coupons from the database. * * @return object List of coupon objects */ function getCoupons() { $virtuemart_vendor_id = vmAccess::getVendorId(); $whereString = ''; if(!empty($virtuemart_vendor_id)){ $whereString = 'WHERE virtuemart_vendor_id="'.$virtuemart_vendor_id.'"'; } return $this->_data = $this->exeSortSearchListQuery(0,'*',' FROM `#__virtuemart_coupons`',$whereString,'',$this->_getOrdering()); } function remove($ids){ if(!vmAccess::manager('coupon.delete')){ vmWarn('Insufficient permissions to remove state'); return false; } return parent::remove($ids); } } // pure php no closing tag