--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+/**
+ * BR-132: Признак промокода для отдельного промо-баланса.
+ */
+class m260220_130000_add_is_promo_balance_to_promocode extends Migration
+{
+ public function safeUp()
+ {
+ $this->addColumn(
+ '{{%erp24.promocode}}',
+ 'is_promo_balance',
+ $this->boolean()->notNull()->defaultValue(false)->comment('Начислять в промо-баланс')
+ );
+ }
+
+ public function safeDown()
+ {
+ $this->dropColumn('{{%erp24.promocode}}', 'is_promo_balance');
+ }
+}
* @property int|null $updated_by ID редактора записи
* @property string $created_at Дата создания
* @property string|null $updated_at Дата изменения
+ * @property bool $is_promo_balance Начислять в промо-баланс (а не в обычные бонусы)
*/
class Promocode extends \yii\db\ActiveRecord
{
return [
[['code', 'bonus', 'duration', 'active', 'date_start', 'date_end', 'created_by', 'created_at'], 'required'],
[['code'], 'string', 'max' => 20],
- [['bonus', 'duration', 'active', 'used', 'base', 'parent_id', 'created_by', 'updated_by'], 'integer'],
+ [['bonus', 'duration', 'active', 'used', 'base', 'parent_id', 'created_by', 'updated_by', 'is_promo_balance'], 'integer'],
[['date_start', 'date_end', 'created_at', 'updated_at'], 'datetime', 'format' => 'php:Y-m-d H:i:s'],
[['updated_by', 'updated_at', 'generatePromocodeCount', 'generateFormat'], 'safe'],
['generateFormat', 'in', 'range' => [self::FORMAT_DIGITS, self::FORMAT_ALPHANUMERIC]],
$singleUsePromocode->parent_id = $basePromocode->id;
$singleUsePromocode->date_start = $basePromocode->date_start;
$singleUsePromocode->date_end = $basePromocode->date_end;
+ $singleUsePromocode->is_promo_balance = $basePromocode->is_promo_balance;
$singleUsePromocode->created_by = Yii::$app->user->id;
$singleUsePromocode->created_at = date("Y-m-d H:i:s");
$singleUsePromocode->save();
$singleUsePromocode->active = $basePromocode->active;
$singleUsePromocode->date_start = $basePromocode->date_start;
$singleUsePromocode->date_end = $basePromocode->date_end;
+ $singleUsePromocode->is_promo_balance = $basePromocode->is_promo_balance;
$singleUsePromocode->save();
if ($singleUsePromocode->getErrors()) {
var_dump($singleUsePromocode->getErrors());
<?php PrintBlockHelper::printBlock('Активность', $form->field($model, 'active')->dropDownList(['Не активен', 'Активен'])->label(false)) ?>
+ <?php PrintBlockHelper::printBlock('Начислять в промо-баланс', $form->field($model, 'is_promo_balance')->dropDownList([0 => 'Нет (обычные бонусы)', 1 => 'Да (промо-баланс)'])->label(false)) ?>
+
<?php PrintBlockHelper::printBlock('Дата начала действия промокода', $form->field($model, 'date_start')->widget(DateTimePicker::class, [
'language' => 'ru',
'template' => '{input}',