diff --git a/backend/controllers/DiscountController.php b/backend/controllers/DiscountController.php index 91a75b8..62aae81 100644 --- a/backend/controllers/DiscountController.php +++ b/backend/controllers/DiscountController.php @@ -65,7 +65,7 @@ class DiscountController extends Controller $model->status = Discount::STATUS_ACTIVE; if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id_warehouse]); + return $this->redirect(['view', 'id' => $model->id_discount]); } else { return $this->render('create', [ 'model' => $model, @@ -84,7 +84,7 @@ class DiscountController extends Controller $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id_warehouse]); + return $this->redirect(['view', 'id' => $model->id_discount]); } else { return $this->render('update', [ 'model' => $model, diff --git a/backend/models/DiscountSearch.php b/backend/models/DiscountSearch.php index 8c97f7f..0a2f640 100644 --- a/backend/models/DiscountSearch.php +++ b/backend/models/DiscountSearch.php @@ -18,7 +18,7 @@ class DiscountSearch extends Discount public function rules() { return [ - [['id_warehouse', 'status', 'type', 'value'], 'integer'], + [['id_discount', 'status', 'type', 'value'], 'integer'], [['name', 'created_at', 'updated_at'], 'safe'], ]; } @@ -56,7 +56,7 @@ class DiscountSearch extends Discount } $query->andFilterWhere([ - 'id_warehouse' => $this->id_warehouse, + 'id_discount' => $this->id_discount, 'status' => $this->status, 'type' => $this->type, 'value' => $this->value, diff --git a/backend/views/discount/update.php b/backend/views/discount/update.php index 8fc2572..b43a463 100644 --- a/backend/views/discount/update.php +++ b/backend/views/discount/update.php @@ -9,7 +9,7 @@ $this->title = Yii::t('common/discount', 'Update {modelClass}: ', [ 'modelClass' => 'Discount', ]) . ' ' . $model->name; $this->params['breadcrumbs'][] = ['label' => Yii::t('common/discount', 'Discounts'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_warehouse]]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_discount]]; $this->params['breadcrumbs'][] = Yii::t('common/discount', 'Update'); ?>
diff --git a/backend/views/discount/view.php b/backend/views/discount/view.php index 1365857..5ce89f3 100644 --- a/backend/views/discount/view.php +++ b/backend/views/discount/view.php @@ -15,9 +15,9 @@ $this->params['breadcrumbs'][] = $this->title;

title) ?>

- $model->id_warehouse], ['class' => 'btn btn-primary']) ?> + $model->id_discount], ['class' => 'btn btn-primary']) ?> $model->id_warehouse], [ +/* Html::a(Yii::t('common/discount', 'Delete'), ['delete', 'id' => $model->id_discount], [ 'class' => 'btn btn-danger', 'data' => [ 'confirm' => Yii::t('common/discount', 'Are you sure you want to delete this item?'), diff --git a/common/components/Helper.php b/common/components/Helper.php new file mode 100644 index 0000000..b705b20 --- /dev/null +++ b/common/components/Helper.php @@ -0,0 +1,16 @@ +type = Transfer::TYPE_PRODUCT; @@ -262,6 +262,9 @@ class Transfer extends \common\models\BaseFitnessActiveRecord $transfer->money_currency = Currency::applyCurrency($totalPrice, $currency); } + $transfer->direction = Transfer::DIRECTION_IN; + $transfer->status = $status; + $transfer->id_account = $account->id_account; return $transfer; diff --git a/console/migrations/m151020_164936_alter__table__discount__timestamps.php b/console/migrations/m151020_164936_alter__table__discount__timestamps.php new file mode 100644 index 0000000..d9ebb16 --- /dev/null +++ b/console/migrations/m151020_164936_alter__table__discount__timestamps.php @@ -0,0 +1,31 @@ +alterColumn('discount', 'created_at', 'datetime' ); + $this->alterColumn('discount', 'updated_at', 'datetime' ); + } + + public function down() + { + echo "m151020_164936_alter__table__discount__timestamps cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/frontend/models/ProductSaleForm.php b/frontend/models/ProductSaleForm.php index 524f2a5..3085f80 100644 --- a/frontend/models/ProductSaleForm.php +++ b/frontend/models/ProductSaleForm.php @@ -60,7 +60,6 @@ class ProductSaleForm extends Model [['id_currency' ], 'validateCurrency'], [['id_account' ], 'validateAccount'], [['id_discount' ], 'validateDiscount'], - [['id_discount' ], 'validateDiscount'], ]; } @@ -130,6 +129,10 @@ class ProductSaleForm extends Model return false; } +// protected function applyDiscount(){ +// Discount::applyDiscount($this->, $discount); +// } + protected function saveTransfer(){ $this->transfer = Transfer::createProductTransfer($this->account, $this->discount, $this->currency, $this->count, $this->product); diff --git a/frontend/web/js/product.sell.js b/frontend/web/js/product.sell.js index 0a719b5..e734e23 100644 --- a/frontend/web/js/product.sell.js +++ b/frontend/web/js/product.sell.js @@ -368,7 +368,7 @@ function ProductSell(o){ function findDiscount(id_discount){ var discount; discount = null; - $.each( app.defaults.discounts , function(e,i){ + $.each( app.defaults.discounts , function(i,e){ if ( e.id_discount == id_discount ){ discount = e; }