Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['index' => ["dataProviderCallback" => function (ActiveDataProvider $activeDataProvider) {
         $activeDataProvider->query->andWhere(['type' => ShopDiscount::TYPE_DEFAULT]);
     }, "gridConfig" => ['settingsData' => ['order' => SORT_ASC, 'orderBy' => "priority"]], "columns" => ['id', ['attribute' => 'name'], ['attribute' => 'value', 'class' => DataColumn::className(), 'value' => function (ShopDiscount $shopDiscount) {
         if ($shopDiscount->value_type == ShopDiscount::VALUE_TYPE_P) {
             return \Yii::$app->formatter->asPercent($shopDiscount->value / 100);
         } else {
             $money = Money::fromString((string) $shopDiscount->value, $shopDiscount->currency_code);
             return \Yii::$app->money->intlFormatter()->format($money);
         }
     }], ['attribute' => 'active', 'class' => BooleanColumn::className()], ['attribute' => 'active_from', 'class' => DateTimeColumnData::className()], ['attribute' => 'active_to', 'class' => DateTimeColumnData::className()], ['class' => UpdatedByColumn::className()], ['class' => UpdatedAtColumn::className()], 'priority']]]);
 }
 /**
  * @return Money
  */
 public function getMoney()
 {
     return Money::fromString($this->price, $this->currency_code);
 }
Exemplo n.º 3
0
/**
 * @author Semenov Alexander <*****@*****.**>
 * @link http://skeeks.com/
 * @copyright 2010 SkeekS (СкикС)
 * @date 02.06.2015
 */
/* @var $this yii\web\View */
/* @var $searchModel \skeeks\cms\models\Search */
/* @var $dataProvider yii\data\ActiveDataProvider */
$dataProvider->query->andWhere(['type' => \skeeks\cms\shop\models\ShopDiscount::TYPE_DEFAULT]);
?>

<? $pjax = \skeeks\cms\modules\admin\widgets\Pjax::begin(); ?>

    <?php 
echo $this->render('_search', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
?>

    <?php 
echo \skeeks\cms\modules\admin\widgets\GridViewStandart::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => $pjax, 'adminController' => \Yii::$app->controller, 'settingsData' => ['order' => SORT_ASC, 'orderBy' => "priority"], 'columns' => ['id', ['attribute' => 'name'], ['attribute' => 'value', 'class' => \yii\grid\DataColumn::className(), 'value' => function (\skeeks\cms\shop\models\ShopDiscount $shopDiscount) {
    if ($shopDiscount->value_type == \skeeks\cms\shop\models\ShopDiscount::VALUE_TYPE_P) {
        return \Yii::$app->formatter->asPercent($shopDiscount->value / 100);
    } else {
        $money = \skeeks\modules\cms\money\Money::fromString((string) $shopDiscount->value, $shopDiscount->currency_code);
        return \Yii::$app->money->intlFormatter()->format($money);
    }
}], ['attribute' => 'active', 'class' => \skeeks\cms\grid\BooleanColumn::className()], ['attribute' => 'active_from', 'class' => \skeeks\cms\grid\DateTimeColumnData::className()], ['attribute' => 'active_to', 'class' => \skeeks\cms\grid\DateTimeColumnData::className()], ['class' => \skeeks\cms\grid\UpdatedByColumn::className()], ['class' => \skeeks\cms\grid\UpdatedAtColumn::className()], 'priority']]);
?>

<? $pjax::end(); ?>
Exemplo n.º 4
0
 /**
  * Новый объект денег с текущей валютой
  *
  * @param string $ammount
  * @return \skeeks\modules\cms\money\Money
  */
 public function newMoney($ammount = '0', $currency = null)
 {
     if ($currency === null) {
         $currency = $this->currencyCode;
     }
     return \skeeks\modules\cms\money\Money::fromString((string) $ammount, $currency);
 }
Exemplo n.º 5
0
 /**
  * Значение налога за одну единицу товара
  *
  * @return Money
  */
 public function getMoneyVat()
 {
     if ((double) $this->vat_rate == 0) {
         return Money::fromString("0", $this->currency_code);
     }
     $value = $this->money->getValue();
     $calculateValue = $value - $value * 100 / 118;
     return Money::fromString((string) $calculateValue, $this->currency_code);
 }
Exemplo n.º 6
0
 /**
  * @return \skeeks\modules\cms\money\Money
  */
 public function getMoneyDelivery()
 {
     if ($this->isNewRecord) {
         return $this->moneyDeliveryFromApi;
     }
     return Money::fromString((string) $this->shipping_cost, "RUB");
 }
Exemplo n.º 7
0
 /**
  * @return Money
  */
 public function getGuidingRealizeMoney()
 {
     return Money::fromString((string) $this->guidingRealizePriceAmount, "RUB");
 }
Exemplo n.º 8
0
 /**
  * TODO: to release
  * @return Money
  */
 public function getPickupMinPrice()
 {
     $minPrice = 0;
     if ($outlets = ArrayHelper::getValue($this->apiData, 'pickup.outlets')) {
         foreach ($outlets as $outletData) {
             if ($outletPrice = ArrayHelper::getValue($outletData, 'guiding_realize_price')) {
                 if ($minPrice == 0 && $outletPrice != 0) {
                     $minPrice = $outletPrice;
                     continue;
                 }
                 if ($outletPrice < $minPrice) {
                     $minPrice = $outletPrice;
                 }
             }
         }
     }
     $minPrice = $minPrice + (int) \Yii::$app->v3toysSettings->pickup_discaunt_value;
     return Money::fromString((string) $minPrice, 'RUB');
 }