本文整理匯總了PHP中Stock::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stock::model方法的具體用法?PHP Stock::model怎麽用?PHP Stock::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Stock
的用法示例。
在下文中一共展示了Stock::model方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionStock
public function actionStock()
{
$criteria = new CDbCriteria();
$criteria->order = "id DESC";
$count = Stock::model()->count($criteria);
$pages = new CPagination($count);
// элементов на страницу
$pages->pageSize = 20;
$pages->applyLimit($criteria);
$stock = Stock::model()->findAll($criteria);
$this->render('stock', array('stock' => $stock, 'pages' => $pages));
}
示例2: actionElement
public function actionElement($param)
{
$paramArr = explode("/", $param);
$paramArr = array_pop($paramArr);
$model = Stock::model()->findByPk($paramArr);
if (empty($model)) {
throw new CHttpException(404, 'The page can not be found.');
}
//Титл и SEO
$this->setSEO(Yii::app()->request->requestUri, 'Статьи', $model);
//Смотрим, нужно ли вставить фотогалерею
$model->description = $this->addPhotogalery($model->description);
Pages::returnUrl(4);
$this->render('view', array('model' => $model));
}
示例3: dirname
<?php
namespace Afosto\ActiveAnts;
require_once dirname(__FILE__) . '/vendor/autoload.php';
//Include our configs
require_once dirname(__FILE__) . '/../config.php';
//Make sure this directory is writable
$cacheDirectory = dirname(__FILE__) . '/../cache/';
App::start($url, $user, $password, $cacheDirectory);
$product = Product::model()->setName('testProduct')->setSku('testSku');
if (!$product->save()) {
echo $product->getMessage();
}
$item = OrderItem::model()->setSku('testSku', false)->setGrossPrice(1.21)->setName('testProduct')->setTaxRate(21);
$address = Address::model()->setName('Afosto SaaS BV')->setAddress('Protonstraat', 9, 'a')->setCity('Groningen')->setCountry('NL')->setPostalcode('9743AL');
$order = Order::model()->setEmail('support@afosto.com')->setOrderId('#' . rand(100, 999))->setPhoneNumber('test')->addOrderItem($item)->setBillingAddress($address)->setShippingAddress();
//$order->setPickupPoint('NL-111101', '1111AA', 'Straatnaam 10a' , 'Groningen');
if (!$order->save()) {
echo $order->getMessage();
}
$purchase = PurchaseOrder::model()->addItem('testSku', 1)->addReference('testPurchaseOrder');
if (!$purchase->save()) {
echo $purchase->getMessage();
}
foreach (Stock::model()->findAll() as $stock) {
echo $stock->sku . ': ' . $stock->stock . "\n";
}
示例4: getLastStock
/**
* @param bool $primary - выводить только те новости, у которых стоит признак "Главные новости"
* @param int $count - количество новостей
* @param int $sort - сортировка 1-по убыванию, 2-по возрастанию
*/
public function getLastStock($primary = true, $count = 3, $sort = 1)
{
$retrnData = null;
$paramArray = array();
if ($primary == true) {
$paramArray[] = '`primary`="1"';
}
$param = implode(" AND ", $paramArray);
$param .= ' ORDER BY maindate ' . ($sort == 1 ? 'DESC' : 'ASC');
$i = 0;
foreach (Stock::model()->findAll($param) as $data) {
$retrnData[] = $data;
if ($i < (int) $count) {
break;
}
++$i;
}
return $retrnData;
}
示例5: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Stock the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Stock::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例6: actionAjax
public function actionAjax()
{
if (isset($_POST)) {
switch ((int) $_POST['type']) {
case 1:
//Смена статуса
$model = $this->loadModel((int) $_POST['id']);
$model->status = $model->status == 1 ? 0 : 1;
$model->save();
//Меняем статус для новостей в группе
foreach (Stock::model()->findAll('group_id = ' . $model->id) as $data) {
$data->status = $model->status;
$data->save();
}
break;
}
echo CJavaScript::jsonEncode('ok');
}
Yii::app()->end();
}
示例7: array
<legend><?php
echo Yii::t("Bootstrap", "LIST.Stock");
?>
</legend>
<?php
$assetsDir = Yii::app()->basePath;
$labels = Stock::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'pages-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->search(), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["name"], 'name' => "name"), array('header' => $labels["brieftext"], 'name' => "brieftext"), array('header' => 'Статус', 'name' => "status", 'type' => 'raw', 'value' => function ($data) {
return '
<a href="#" class="on-off-product" data-id="' . $data->id . '" data-status="' . $data->status . '">
<div style="margin-left:20px; width: 13px; height: 13px; border-radius: 3px; background:' . ($data->status == 1 ? 'green' : 'red') . '"></div>
</a>
';
}, 'filter' => ''), array('header' => $labels["primary"], 'name' => "primary", 'value' => 'Stock::model()->getDownliststatus($data->primary)', 'filter' => Stock::model()->getStatuslist()), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update} {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap')))));
?>
<a href="/admin/<?php
echo Yii::app()->controller->module->id;
?>
/<?php
echo Yii::app()->controller->id;
?>
/create" class="btn">Добавить новость</a>
<script>
//Меняем статус
$(document).on('click', '.on-off-product', function(){
$.ajax({
type: 'POST',
示例8: array
?>
<br>
<?php
echo CHtml::activeFileField($model, 'imagefile', array('style' => 'cursor: pointer;'));
?>
</div>
</div>
<?php
echo $form->DatePickerRow($model, 'maindate', array('options' => array('autoclose' => true, 'type' => 'Component', 'format' => 'yyyy-mm-dd'), 'htmlOptions' => array()));
?>
<?php
echo $form->dropDownListRow($model, 'status', Stock::model()->getStatuslist(), array('class' => 'span5'));
?>
<div class="form-actions">
<?php
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'htmlOptions' => array('style' => 'margin-right: 20px'), 'label' => $model->isNewRecord ? Yii::t('Bootstrap', 'PHRASE.BUTTON.CREATE') : Yii::t('Bootstrap', 'PHRASE.BUTTON.SAVE')));
?>
<?php
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'link', 'label' => Yii::t('Bootstrap', 'PHRASE.BUTTON.RETURN'), 'url' => $this->listUrl('index')));
?>
</div>