本文整理汇总了PHP中Stock类的典型用法代码示例。如果您正苦于以下问题:PHP Stock类的具体用法?PHP Stock怎么用?PHP Stock使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Stock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: refund
public function refund($id)
{
$compra = new Compra();
$usuario = new Usuario();
$stock = new Stock();
$info = $this->joinCompra($id);
/**
* @internal Resto de la compra
* @param num
* @param user
* @param id
*/
$newTotal = $info->total - $info->pagado;
try {
$compra->setTotal($newTotal, $info->user, $info->compra);
$usuario->sumarCredito($info->pagado, $info->user);
$stock->sumStock($info->talle, $info->color, $info->cantidad, $info->producto);
$this->delete($id);
if ($compra->isEmpty($info->compra)) {
$compra->delete($info->compra);
}
header('location: ' . $_SESSION['last_page']);
} catch (PDOException $e) {
echo $e->getMessage();
}
}
示例3: actionCreate
/**
* Creates a new Stock model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Stock();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例4: removeStock
public static function removeStock($item, $location, $quantity, $date)
{
$stock = new Stock();
$stock->date = $date;
$stock->item()->associate($item);
$stock->location()->associate($location);
$stock->quantity_out = $quantity;
$stock->save();
}
示例5: _titoli
function _titoli($mercato)
{
$conn = $this->get_connection();
$stock_factory = new Stock();
$stocks = $stock_factory->find_all(array('where_clause' => "`attivo` = 1 " . ($mercato !== NULL ? " AND `mercato` = '{$conn->escape($mercato)}' " : ''), 'order_by' => '`title` ASC ', 'limit' => 99999999));
if (count($stocks) > 0) {
$this->stocks = array_map(function ($t) {
return "\t{\n\t\t\"isin\": \"" . $t->isin . "\",\n\t\t\"title\": \"" . $t->title . "\"\n\t}";
}, $stocks);
}
$this->render(array('action' => 'titoli', 'layout' => FALSE));
}
示例6: update_all_daily_data
function update_all_daily_data()
{
$status = '';
$query = mysql_query("SELECT * FROM stocks");
while ($array = mysql_fetch_array($query)) {
$stock = new Stock($array);
if (update_stock_daily($stock->getTicker())) {
$status .= 'Successfully Updated all stock info for ' . $stock->getTicker() . '<br />';
} else {
$status .= 'Failed to update stock ' . $stock->getTicker() . '<br />';
}
}
return $status;
}
示例7: preferiti
/**
* @fn preferiti
* @short Lists favorite instruments
* @details Action to list favorite instruments for the current user,
* filtered by attributes like market, type, currency, and sorted by any of
* the columns (defaults to <code>title</code>).
*/
public function preferiti()
{
$conn = $this->get_connection();
$stock_factory = new Stock();
$query = 'SELECT * FROM `creso_titoli` LEFT JOIN `creso_preferiti` ON `creso_titoli`.`isin` = `creso_preferiti`.`isin` ' . "WHERE " . (is_numeric($_REQUEST['attivo']) ? "`attivo` = {$conn->escape($_REQUEST['attivo'])} " : '`attivo` = 1 ') . "AND `utente` = '{$conn->escape($_COOKIE['username'])}' " . (!empty($_REQUEST['mercato']) ? "AND `mercato` = '{$conn->escape($_REQUEST['mercato'])}' " : '') . (!empty($_REQUEST['tipo']) ? "AND `tipo` = '{$conn->escape($_REQUEST['tipo'])}' " : '') . (!empty($_REQUEST['divisa']) ? "AND `divisa` = '{$conn->escape($_REQUEST['divisa'])}' " : '') . "ORDER BY `{$conn->escape($this->get_sort('title'))}` {$conn->escape($this->get_dir())} " . "LIMIT {$conn->escape($this->get_start())}, {$conn->escape($this->get_limit())}";
$this->stocks = $stock_factory->find_by_query($query);
$query = 'SELECT COUNT(*) FROM `creso_titoli` LEFT JOIN `creso_preferiti` ON `creso_titoli`.`isin` = `creso_preferiti`.`isin` ' . "WHERE " . (is_numeric($_REQUEST['attivo']) ? "`attivo` = {$conn->escape($_REQUEST['attivo'])} " : '`attivo` = 1 ') . "AND `utente` = '{$conn->escape($_COOKIE['username'])}' " . (!empty($_REQUEST['mercato']) ? "AND `mercato` = '{$conn->escape($_REQUEST['mercato'])}' " : '') . (!empty($_REQUEST['tipo']) ? "AND `tipo` = '{$conn->escape($_REQUEST['tipo'])}' " : '') . (!empty($_REQUEST['divisa']) ? "AND `divisa` = '{$conn->escape($_REQUEST['divisa'])}' " : '');
$conn->prepare($query);
$conn->exec();
$this->count = $conn->fetch_array()[0];
$conn->free_result();
$this->is_favorite = TRUE;
$this->render(array('action' => 'index'));
}
示例8: add
function add()
{
if ($this->request->is_post()) {
$item = new Dividend($_POST);
$item->save();
$this->redirect_to(array('action' => 'index'));
} else {
$stock_factory = new Stock();
$stocks = $stock_factory->find_all(array('where_clause' => '`attivo` = 1', 'order_by' => '`title` ASC'));
$this->stocks = array('-1' => 'Scegli...');
foreach ($stocks as $stock) {
$this->stocks[$stock->isin] = $stock->title;
}
}
}
示例9: refunds
public static function refunds($isin, $month_from, $month_to)
{
$payments = array();
$conn = Db::get_connection();
$stock = new Stock();
if (!$stock->find_by_id($isin)) {
return;
}
switch ($stock->tipo) {
case 'azione':
break;
case 'obbligazione':
$bond_factory = new Bond();
$bonds = $bond_factory->find_all(array('where_clause' => "`isin` = '{$conn->escape($isin)}' " . "AND `scadenza` >= '{$conn->escape($month_from)}' " . "AND `scadenza` <= '{$conn->escape($month_to)}' "));
if (count($bonds) > 0) {
$bond = $bonds[0];
$payment = new Payment();
$payment->stock = $stock;
$payment->bond = $bond;
$payment->timestamp = strtotime($bond->scadenza);
$payment->importo = $payment->bond->prezzo_rimborso;
$payment->tipo = 'rimborso';
$payments[] = $payment;
}
break;
}
return $payments;
}
示例10: add
function add()
{
if ($this->request->is_post()) {
$transaction = new Transaction($_POST);
// Salvo la transazione
$transaction->save();
$this->redirect_to(array('action' => 'index'));
} else {
$stock_factory = new Stock();
$stocks = $stock_factory->find_all(array('where_clause' => "`attivo` = 1 ", 'order_by' => '`title` ASC', 'limit' => 9999));
$this->stocks = array('' => 'Scegli...');
foreach ($stocks as $stock) {
$this->stocks[$stock->isin] = $stock->title;
}
}
}
示例11: run
public function run($context)
{
$stock_factory = new Stock();
$stocks = $stock_factory->find_by_query('SELECT * FROM `creso_titoli` ' . 'LEFT JOIN `creso_obbligazioni` ON `creso_titoli`.`isin` = `creso_obbligazioni`.`isin` ' . 'WHERE ' . "`creso_titoli`.`tipo` = 'obbligazione' " . 'AND ' . "`creso_obbligazioni`.`emissione` = '0000-00-00' " . 'AND ' . '`creso_titoli`.`attivo` = 1 ' . 'LIMIT 1500');
$updated_count = 0;
foreach ($stocks as $stock) {
$bond = new Bond();
$bond->find_by_id($stock->isin);
$bond->emissione = isin2emissione_ariva($stock->isin);
if ($bond->emissione != '0000-00-00') {
$bond->save();
$updated_count++;
}
}
printf("%s updated %d bonds\n", get_called_class(), $updated_count);
}
示例12: inventory
public static function inventory()
{
return function ($request, $response) {
if ($request->session('admin')) {
try {
$response->header('Content-Type', 'application/pdf');
$stocks_report = Zend_Pdf::load('../pdf/inv.pdf');
$page = $stocks_report->pages[0];
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_COURIER);
$page->setFont($font, 10);
$page->drawText(Time::unixToDate(time()), 290, 818);
$row = 765;
$stocks = Stock::all();
foreach ($stocks as $stock) {
$page->drawText(sprintf("%10.39s", $stock->product->name), 32, $row);
$page->drawText($stock->product->description, 280, $row);
$page->drawText(sprintf("%4u", $stock->quantity), 550, $row);
$row -= 15;
}
$page->drawText("Prepared by:", 300, 80);
$page->drawText("________________________________", 300, 50);
echo $stocks_report->render();
} catch (Exception $e) {
$response->header('Content-Type', 'text/plain');
echo $e->getMessage();
}
} else {
$response->code(403);
}
};
}
示例13: test_aroundLockProductsStock_process
public function test_aroundLockProductsStock_process()
{
/** === Test Data === */
$PROD_IDS = [[]];
$STOCK_ID = 1;
$TAB_STOCK = 'table 01';
$TAB_PROD = 'table 02';
$RESULT = 'result';
/** === Setup Mocks === */
$mProceed = function () {
};
// $conn = $subject->getConnection();
$mConn = $this->_mockConn();
$this->mSubject->shouldReceive('getConnection')->once()->andReturn($mConn);
// $itemTable = $subject->getTable('cataloginventory_stock_item');
$this->mSubject->shouldReceive('getTable')->once()->with('cataloginventory_stock_item')->andReturn($TAB_STOCK);
// $productTable = $subject->getTable('catalog_product_entity');
$this->mSubject->shouldReceive('getTable')->once()->with('catalog_product_entity')->andReturn($TAB_PROD);
// $select = $conn->select();
$mSelect = $this->_mockDbSelect(['from', 'join', 'where', 'forUpdate']);
$mConn->shouldReceive('select')->once()->andReturn($mSelect);
// $result = $conn->fetchAll($select);
$mConn->shouldReceive('fetchAll')->once()->andReturn($RESULT);
/** === Call and asserts === */
$res = $this->obj->aroundLockProductsStock($this->mSubject, $mProceed, $PROD_IDS, $STOCK_ID);
$this->assertEquals($RESULT, $res);
}
示例14: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Stock::create([]);
}
}
示例15: run
public function run()
{
$object = [["ID_PRODUCTO" => "10", "CANTIDAD" => "101", "ID_BODEGA" => "1"], ["ID_PRODUCTO" => "20", "CANTIDAD" => "10", "ID_BODEGA" => "1"], ["ID_PRODUCTO" => "1", "CANTIDAD" => "55", "ID_BODEGA" => "1"]];
DB::unprepared('ALTER TABLE ' . $this->table . ' AUTO_INCREMENT = 1');
foreach ($object as $detail) {
Stock::create($detail);
}
}