iaPlan::setUnpaid PHP Method

setUnpaid() public method

public setUnpaid ( $itemName, $itemId )
    public function setUnpaid($itemName, $itemId)
    {
        // first, try to update DB record
        $tableName = $this->iaCore->factory('item')->getItemTable($itemName);
        $stmt = iaDb::convertIds($itemId);
        $entry = $this->iaDb->row(array(self::SPONSORED, self::SPONSORED_PLAN_ID), $stmt, $tableName);
        if (empty($entry) || !$entry[self::SPONSORED] || !isset($entry['member_id'])) {
            return false;
        }
        $values = array(self::SPONSORED => 0, self::SPONSORED_PLAN_ID => 0, self::SPONSORED_DATE_START => null, self::SPONSORED_DATE_END => null);
        $plan = $this->getById($entry[self::SPONSORED_PLAN_ID]);
        if (!empty($plan['expiration_status'])) {
            $values['status'] = $plan['expiration_status'];
        }
        $result = $this->iaDb->update($values, $stmt, null, $tableName);
        $this->_sendEmailNotification('expired', $plan, $entry['member_id']);
        // then, try to call class' helper
        $this->_runClassMethod($itemName, self::METHOD_CANCEL_PLAN, array($itemId));
        return $result;
    }