/** * Checks and repairs the internal consistency of the object. * * This method is executed after an already-instantiated object is re-hydrated * from the database. It exists to check any foreign keys to make sure that * the objects related to the current object are correct based on foreign key. * * You can override this method in the stub class, but you should always invoke * the base method from the overridden method (i.e. parent::ensureConsistency()), * in case your model changes. * * @throws PropelException */ public function ensureConsistency() { if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { $this->aProduct = null; } if ($this->aAttributeAv !== null && $this->attribute_av_id !== $this->aAttributeAv->getId()) { $this->aAttributeAv = null; } if ($this->aCurrency !== null && $this->currency_id !== $this->aCurrency->getId()) { $this->aCurrency = null; } }
/** * Set $currency as default * * @param Currency $currency * @return boolean */ function setDefault($currency) { if ($currency->getIsDefault()) { return true; } // if db_begin_work(); $currency->setIsDefault(true); $update = $currency->save(); if ($update && !is_error($update)) { $update = db_execute('UPDATE ' . TABLE_PREFIX . 'currencies SET is_default = ? WHERE id != ?', false, $currency->getId()); cache_remove_by_pattern(TABLE_PREFIX . 'currencies_id_*'); if ($update && !is_error($update)) { db_commit(); return true; } // if } // if db_rollback(); return $update; }
/** * Declares an association between this object and a Currency object. * * @param Currency $v * @return Country The current object (for fluent API support) * @throws PropelException */ public function setCurrency(Currency $v = null) { if ($v === null) { $this->setDefaultCurrencyId(NULL); } else { $this->setDefaultCurrencyId($v->getId()); } $this->aCurrency = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Currency object, it will not be re-added. if ($v !== null) { $v->addCountry($this); } return $this; }
/** * Filter the query by a related Currency object * * @param Currency|PropelObjectCollection $currency The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return CountryQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByCurrency($currency, $comparison = null) { if ($currency instanceof Currency) { return $this->addUsingAlias(CountryPeer::DEFAULT_CURRENCY_ID, $currency->getId(), $comparison); } elseif ($currency instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(CountryPeer::DEFAULT_CURRENCY_ID, $currency->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByCurrency() only accepts arguments of type Currency or PropelCollection'); } }
private static function EGOP_MinAndMaxWallets(Currency $currency) { $wallets = WalletsEgop::findBy(array('currency_id' => $currency->getId())); if (empty($wallets)) { return null; } $maxBalance = null; $keyMax = null; $minBalance = null; $keyMin = null; foreach ($wallets as $key => $value) { $oAuth = new EgoPayAuth($value['email'], $value['api_id'], $value['api_password']); $oEgoPayJsonAgent = new EgoPayJsonApiAgent($oAuth); $oEgoPayJsonAgent->setVerifyPeer(false); try { $balance = $oEgoPayJsonAgent->getBalance($currency->getName()); if ($minBalance === null || $minBalance > $balance) { $minBalance = $balance; $keyMin = $key; } if ($maxBalance === null || $maxBalance < $balance) { $maxBalance = $balance; $keyMax = $key; } } catch (EgoPayApiException $e) { Core::write_log(EGOPAY_LOG_PATH, __FUNCTION__ . ' : getBalance Error: ' . $e->getCode() . " : " . $e->getMessage()); } } $result['min'] = $wallets[$keyMin]; $result['max'] = $wallets[$keyMax]; return $result; }
/** * Exclude object from result * * @param Currency $currency Object to remove from the list of results * * @return CurrencyQuery The current query, for fluid interface */ public function prune($currency = null) { if ($currency) { $this->addUsingAlias(CurrencyPeer::ID, $currency->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Return number of invoices that use $currency * * @param Currency $currency * @return integer */ function countByCurrency($currency) { return Invoices::count(array('currency_id = ?', $currency->getId())); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Currency $obj A Currency object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Checks and repairs the internal consistency of the object. * * This method is executed after an already-instantiated object is re-hydrated * from the database. It exists to check any foreign keys to make sure that * the objects related to the current object are correct based on foreign key. * * You can override this method in the stub class, but you should always invoke * the base method from the overridden method (i.e. parent::ensureConsistency()), * in case your model changes. * * @throws PropelException */ public function ensureConsistency() { if ($this->aCountry !== null && $this->default_country_id !== $this->aCountry->getId()) { $this->aCountry = null; } if ($this->aCurrency !== null && $this->default_currency_id !== $this->aCurrency->getId()) { $this->aCurrency = null; } }
public static function addNewEGOPWallet() { $email = Core::validate($_POST['EMAIL']); $api_id = Core::validate($_POST['API_ID']); $api_password = Core::validate($_POST['API_PASSWORD']); $store_id = Core::validate($_POST['STORE_ID']); $store_password = Core::validate($_POST['STORE_PASSWORD']); $checksum_key = Core::validate($_POST['CHECKSUM_KEY']); $currency_name = Core::validate($_POST['CURRENCY']); $share = Core::validate($_POST['SHARE']); // percent if ($email == null || $api_id == null || $api_password == null || $store_id == null || $store_password == null || $checksum_key == null || $currency_name == null || $share == null || !Core::isDouble($share)) { print 'Incorrect data'; exit; } $currency = new Currency(); if (!$currency->findBy(array('Name' => $currency_name))) { exit; } $result = WalletsEgop::findBy(array('currency_id' => $currency->getId(), 'email' => $email)); if (!empty($result)) { print 'This wallet already exists'; exit; } $oAuth = new EgoPayAuth($email, $api_id, $api_password); $oEgoPayJsonAgent = new EgoPayJsonApiAgent($oAuth); $oEgoPayJsonAgent->setVerifyPeer(false); try { $balance = $oEgoPayJsonAgent->getBalance($currency->getName()); } catch (EgoPayApiException $e) { Core::write_log(EGOPAY_LOG_PATH, __FUNCTION__ . ' : getBalance Error: ' . $e->getCode() . " : " . $e->getMessage()); print $e->getMessage(); exit; } $wallet = new WalletsEgop(); $wallet->setCurrencyId($currency->getId()); $wallet->setEmail($email); $wallet->setApiId($api_id); $wallet->setApiPassword($api_password); $wallet->setStoreId($store_id); $wallet->setStorePassword($store_password); $wallet->setChecksumKey($checksum_key); $wallet->setValue($balance); $wallet->setShare($share / 100.0); $wallet->insert(); header('Location: /admin/egop'); }
public static function getRate($firstCurName, $secondCurName) { $searchConditions = array(); $firstCurrency = new Currency(); $searchConditions['Name'] = $firstCurName; if (!$firstCurrency->findBy($searchConditions)) { return null; } $secondCurrency = new Currency(); $searchConditions['Name'] = $secondCurName; if (!$secondCurrency->findBy($searchConditions)) { return null; } $rate = new Rate(); $searchConditions = array(); $searchConditions['FirstId'] = $firstCurrency->getId(); $searchConditions['SecondId'] = $secondCurrency->getId(); if (!$rate->findBy($searchConditions)) { return null; } return $rate; }
/** * @param Currency $currency * @return $this */ public function addCurrency($currency) { $this->currencies[$currency->getId()] = $currency; return $this; }