本文整理汇总了PHP中Change类的典型用法代码示例。如果您正苦于以下问题:PHP Change类的具体用法?PHP Change怎么用?PHP Change使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Change类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process(&$return, $req)
{
$cf = new Change($this->settings, $this->changeFactory, $this->changeFactory->getCacher());
$cf->parseFile(DBC_EXECUTION_MODE == 'web' ? $req['file'] : $req[0]);
$cf->setIsExecuted(true);
$return['data'] = $cf->getAsyncStatus();
}
示例2: process
public function process(&$return, $req)
{
$cf = new Change($this->settings, $this->changeFactory, $this->changeFactory->getCacher());
$cf->parseFile(DBC_EXECUTION_MODE == 'web' ? $req['file'] : $req[0]);
//only if the setting api_execute_async is true and execution_mode is web, then execute it async
$async = $this->settings->getApiExecuteAsync() && DBC_EXECUTION_MODE == 'web';
$return['data'] = $cf->executeSql($async);
}
示例3: test_for_pennies
function test_for_pennies()
{
//Arrange
$test_user_input = new Change();
$user_change = 4;
//Act
$result = $test_user_input->giveChange($user_change);
//Assert
$this->assertEquals([0, 0, 0, 4], $result);
}
示例4: test_getPennies
function test_getPennies()
{
// Arrange
$new_Change = new Change();
$input = 46;
// Act
$result = $new_Change->makeChange($input);
// Assert
$this->assertEquals("quarters:1 dimes:2 nickels:0 pennies:1", $result);
}
示例5: test_calculateOneQuarterOneDimeOneNickelFourPennies
function test_calculateOneQuarterOneDimeOneNickelFourPennies()
{
//Arrange
$test_Change = new Change();
$input = 44;
//Act
$result = $test_Change->calculateChange($input);
//Assert
$this->assertEquals(array('pennies' => 4, 'nickels' => 1, 'dimes' => 1, 'quarters' => 1), $result);
}
示例6: canCreateItem
/**
* Is the current user have right to create the current task ?
*
* @return boolean
**/
function canCreateItem()
{
if (!parent::canReadITILItem()) {
return false;
}
$change = new Change();
if ($change->getFromDB($this->fields['changes_id'])) {
return Session::haveRight('change', UPDATE) || Session::haveRight('change', Change::READMY) && ($change->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $change->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']));
}
return false;
}
示例7: run
public function run($context)
{
$changes = changes_eurotlx();
$change = new Change();
$change->data = date('Y-m-d H:i:s');
foreach ($changes as $key => $val) {
$change->{$key} = $val;
}
$change->_force_create = TRUE;
$change->save();
printf("%s saved currency change rates\n", get_called_class());
}
示例8: _populate_transactions
function _populate_transactions()
{
$conn = $this->get_connection();
if (count($this->transactions) > 0) {
foreach ($this->transactions as $transaction) {
$transaction->stock = new Stock();
$transaction->stock->find_by_id($transaction->isin);
$transaction->importo = 0;
$parts = $transaction->find_all(array('where_clause' => "`negot_id` = '{$conn->escape($transaction->negot_id)}'"));
if (count($parts) > 0) {
foreach ($parts as $part) {
$importo = $part->quantita * $part->prezzo;
$importo /= $transaction->stock->divisa == 'USD' ? Change::usd2eur($part->data) : 1;
$importo *= $part->azione == 'acquisto' ? -1 : 1;
$importo /= $transaction->stock->tipo == 'obbligazione' ? 100 : 1;
$comm = abs($importo) * $this->preference->comm_percent;
if (strtotime($part->data) >= strtotime("2007-08-01")) {
$comm = $comm > $this->preference->comm_percent_min ? $comm : $this->preference->comm_percent_min;
}
$importo -= $comm;
$importo -= $this->preference->comm_fissa;
$transaction->importo += $importo;
}
}
$this->bilancio += $transaction->importo;
}
}
}
示例9: importo_eur
public function importo_eur()
{
if (!isset($this->importo_eur)) {
$this->importo_eur = Change::convert($this->importo, $this->stock->divisa, date('Y-m-d', $this->timestamp));
}
return $this->importo_eur;
}
示例10: roi_with_timeline
public static function roi_with_timeline($isin, $username, $month_from, $month_to)
{
$conn = Db::get_connection();
$stock = new Stock();
if (!$stock->find_by_id($isin)) {
return;
}
$portfolio_stock_factory = new PortfolioStock();
$portfolio_stocks = $portfolio_stock_factory->find_all(array('where_clause' => "`isin` = '{$conn->escape($isin)}' " . "AND `utente` = '{$conn->escape($username)}'"));
if (count($portfolio_stocks) == 0) {
return;
}
$portfolio_stock = $portfolio_stocks[0];
$quantita = self::quantita_history($isin, $username, $month_from);
switch ($stock->tipo) {
case 'obbligazione':
$investito = $portfolio_stock->prezzo * $portfolio_stock->quantita / 100;
break;
default:
$investito = $portfolio_stock->prezzo * $portfolio_stock->quantita;
}
$investito = Change::convert($investito, $stock->divisa);
$roi = PianificatoreHelper::roi_with_timeline($isin, $quantita, $month_from, $month_to, $investito);
foreach ($roi->payments as $payment) {
$payment->portfolio_stock = $portfolio_stock;
}
// print_r($roi);
return $roi;
}
示例11: index
/**
* Action methods
*/
public function index()
{
//$this->last = Change::usd2eur();
$conn = $this->get_connection();
$yesterday = date('Y-m-d', mktime(0, 0, 0, isset($_REQUEST['month']) ? $_REQUEST['month'] : date('m'), (isset($_REQUEST['day']) ? $_REQUEST['day'] : date('d')) - 1, isset($_REQUEST['year']) ? $_REQUEST['year'] : date('Y')));
$tomorrow = date('Y-m-d', mktime(0, 0, 0, isset($_REQUEST['month']) ? $_REQUEST['month'] : date('m'), (isset($_REQUEST['day']) ? $_REQUEST['day'] : date('d')) + 1, isset($_REQUEST['year']) ? $_REQUEST['year'] : date('Y')));
$change = new Change();
$changes = $change->find_by_query('SELECT `data`, `usd2eur` ' . 'FROM `creso_cambi` ' . "WHERE 1 " . "AND `data` > '{$conn->escape($yesterday)}' " . "AND `data` < '{$conn->escape($tomorrow)}' " . 'ORDER BY `usd2eur` DESC ' . 'LIMIT 1');
$this->day_max = $changes[0];
$changes = $change->find_by_query('SELECT `data`, `usd2eur` ' . 'FROM `creso_cambi` ' . "WHERE 1 " . "AND `data` > '{$conn->escape($yesterday)}' " . "AND `data` < '{$conn->escape($tomorrow)}' " . 'ORDER BY `usd2eur` ASC ' . 'LIMIT 1');
$this->day_min = $changes[0];
$changes = $change->find_by_query('SELECT `data`, `usd2eur` ' . 'FROM `creso_cambi` ' . "WHERE 1 " . "AND `data` > '{$conn->escape($yesterday)}' " . "AND `data` < '{$conn->escape($tomorrow)}' " . 'ORDER BY `data` ASC ' . 'LIMIT 1');
$this->open = $changes[0];
$changes = $change->find_by_query('SELECT `data`, `usd2eur` ' . 'FROM `creso_cambi` ' . "WHERE 1 " . "AND `data` > '{$conn->escape($yesterday)}' " . "AND `data` < '{$conn->escape($tomorrow)}' " . 'ORDER BY `data` DESC ' . 'LIMIT 1');
$this->last = $changes[0];
$this->redirect_to(array_merge($_REQUEST, array('query_string' => $this->request->querystring, 'after' => 300)));
}
示例12: _partitionByType
/**
* Returns the changes partitioned by change type.
*
* @return array An array of type => array of changes.
*/
protected function _partitionByType()
{
$types = Change::types();
$result = array_combine(array_keys($types), array_fill(0, count($types), []));
foreach ($this->_changes as $change) {
$result[$change->getType()][] = $change;
}
return array_filter($result);
}
示例13: test_accessors
public function test_accessors()
{
/** === Test Data === */
$CUST_ID = 'cust ID';
$DATE_CHANGED = 'changed at';
$ID = 'id';
$PARENT_ID = 'id';
/** === Call and asserts === */
$this->obj->setCustomerId($CUST_ID);
$this->obj->setDateChanged($DATE_CHANGED);
$this->obj->setId($ID);
$this->obj->setParentId($PARENT_ID);
$this->assertEquals($CUST_ID, $this->obj->getCustomerId());
$this->assertEquals($DATE_CHANGED, $this->obj->getDateChanged());
$this->assertEquals($ID, $this->obj->getId());
$this->assertEquals($PARENT_ID, $this->obj->getParentId());
}
示例14: process
public function process(&$return, $req)
{
if (DBC_EXECUTION_MODE != 'cli') {
throw new Exception('runAll is only valid in CLI mode.');
}
parent::process($return, $req);
$cardStack = (array) $return['data'];
$cardStack = array_reverse($cardStack);
//execute in reverse order
$errCount = 0;
$cardCount = sizeof($cardStack);
foreach ($cardStack as $entry) {
try {
$changeFile = $entry['file'];
$cf = new Change($this->settings, $this->changeFactory, $this->changeFactory->getCacher());
$cf->parseFile($changeFile);
try {
if (!$cf->doExecuteSql()) {
$errStat = $cf->getAsyncStatus();
throw new Exception($errStat['message']);
}
echo '[DONE] ' . $changeFile . PHP_EOL;
} catch (Exception $e) {
$errCount++;
echo '[FAILED] ' . $changeFile . ' :: ' . $e->getMessage() . PHP_EOL;
echo $cf->getSql() . PHP_EOL;
if (in_array('--force', $req) || in_array('-f', $req)) {
try {
$cf->failedToExecuted();
echo '[IGNORE] ' . $changeFile . PHP_EOL;
} catch (Exception $e) {
echo '[FAILED] ' . $changeFile . ' IGNORE FAILED :: ' . $e->getMessage() . PHP_EOL;
}
}
}
} catch (Execution $e) {
echo '[FAILED] ' . $changeFile . ' Unrecoverable error :: ' . $e->getMessage() . PHP_EOL;
}
if (sizeof($cf->getExecute())) {
echo '[IGNORE] ' . $changeFile . ' PATCHES: ' . implode(', ', $cf->getExecute()) . PHP_EOL;
}
}
$return['data'] = PHP_EOL . '*** FINISHED ' . $cardCount . ' CHANGES' . ($errCount ? ' WITH ' . $errCount . ' FAIL(S)' : ' SUCCESSFULLY');
$return['status'] = 'ok';
}
示例15: store
/**
* @param ChangeFile $cf
* @param bool $overwrite
* @throws Exception
*/
public function store(Change $cf, $overwrite = true)
{
if ($cf->getIssueNumber() == '') {
throw new Exception('Issue# is empty.');
}
if ((int) $cf->getIssueCount() == 0) {
throw new Exception('Issue Count is empty.');
}
$filename = $cf->generateFilename($cf->getIssueNumber(), $cf->getIssueCount());
if (!$overwrite) {
if (parent::fileExists($this->getDir(self::FILE_ROOT), $filename)) {
throw new Exception('Change already exists.');
}
}
parent::save($this->getDir(self::FILE_ROOT), $filename, $cf->stringify());
}