<?= $form->field($model, 'id_user')->dropDownList(User::populateDropdownList()); ?> | <?= $form->field($model, 'id_user')->dropDownList(User::populateDropdownList()); ?> | ||||
<?= $form->field($model, 'id_user_group')->dropDownList(UserGroup::populateDropdownList()); ?> | <?= $form->field($model, 'id_user_group')->dropDownList(UserGroup::populateDropdownList()); ?> | ||||
<?= $form->field($model, 'id_point_sale')->dropDownList(PointSale::populateDropdownList()); ?> | <?= $form->field($model, 'id_point_sale')->dropDownList(PointSale::populateDropdownList()); ?> | ||||
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('.Product::strUnit($modelProduct->unit, 'wording').')'); ?> | |||||
<?php | <?php | ||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); |
return '<span class="label label-success">Tous</span>' ; | return '<span class="label label-success">Tous</span>' ; | ||||
} | } | ||||
], | ], | ||||
[ | |||||
'attribute' => 'from_quantity', | |||||
'value' => function ($productPrice) { | |||||
if($productPrice->from_quantity) { | |||||
return $productPrice->from_quantity.' '.$productPrice->product->wording_unit; | |||||
} | |||||
return '' ; | |||||
} | |||||
], | |||||
[ | [ | ||||
'attribute' => 'price', | 'attribute' => 'price', | ||||
'value' => function ($productPrice) { | 'value' => function ($productPrice) { |
}, 'message' => 'Vous devez renseigner au moins un utilisateur, un point de vente ou un groupe d\'utilisateur'], | }, 'message' => 'Vous devez renseigner au moins un utilisateur, un point de vente ou un groupe d\'utilisateur'], | ||||
[['id_product', 'price'], 'required'], | [['id_product', 'price'], 'required'], | ||||
[['id_product', 'id_user', 'id_point_sale', 'id_user_group', 'percent'], 'integer'], | [['id_product', 'id_user', 'id_point_sale', 'id_user_group', 'percent'], 'integer'], | ||||
[['price'], 'double'], | |||||
[['price', 'from_quantity'], 'double'], | |||||
]; | ]; | ||||
} | } | ||||
'id_user_group' => "Groupe d'utilisateur", | 'id_user_group' => "Groupe d'utilisateur", | ||||
'price' => 'Prix (HT)', | 'price' => 'Prix (HT)', | ||||
'percent' => 'Pourcentage', | 'percent' => 'Pourcentage', | ||||
'from_quantity' => 'À partir de la quantité', | |||||
]; | ]; | ||||
} | } | ||||
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
/** | |||||
* Class m220804_095203_prix_degressifs_champs_from_quantity | |||||
*/ | |||||
class m220804_095203_prix_degressifs_champs_from_quantity extends Migration | |||||
{ | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('product_price', 'from_quantity', Schema::TYPE_FLOAT.' DEFAULT NULL'); | |||||
} | |||||
/** | |||||
* {@inheritdoc} | |||||
*/ | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('product_price', 'from_quantity'); | |||||
} | |||||
} |