Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
<?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('*****@*****.**')->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";
}
Ejemplo n.º 4
0
 /**
  * @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;
 }
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
 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();
 }
Ejemplo n.º 7
0
<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',
Ejemplo n.º 8
0
?>
        <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>