Closed NguyenVanHoang2779 closed 2 years ago
Image error display for me : https://im.ge/i/Uoauh [Controller] public function actionUpdate() { $searchModel = new RewardPercentSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); if (Yii::$app->request->post("hasEditable")) { $rewardPercent_id = Yii::$app->request->post('editableKey'); $model = LwRewardPercent::findOne($rewardPercent_id); $posted = current($_POST['LwRewardPercent']); $name_post_column = $_POST['editableAttribute']; $model->$name_post_column = $posted[$name_post_column];
if($name_post_column == 'percent'){ if ($this->getSummaryPercent() <= 100) { $model->save(); $output = ''; $out = Json::encode(['output' => $output, 'message' => '']); } else { $output = $model->attributes['percent'];; $out = Json::encode(['output' => $output, 'message' => 'cannot be changed due to total other 100']); } } else{ if($posted[$name_post_column] ==0){ $output = $model->attributes['reward_per_day']; $out = Json::encode(['output' => $output, 'message' => 'Reward per day cannot be 0']); } else { $model->save(); $output = ''; $out = Json::encode(['output' => $output, 'message' => '']); } } echo $out; return; } return $this->render('update', [ 'dataProvider' => $dataProvider, ]); }
Vỉew <?php
use common\models\LwRewardPercent; use yii\helpers\Html; use kartik\grid\GridView;
/ @var $this yii\web\View / / @var $searchModel common\models\RewardPercentSearch / / @var $dataProvider yii\data\ActiveDataProvider /
$this->title = ' '; $this->params['breadcrumbs'][] = ['label' => 'Reward Percent', 'url' => ['index']]; $this->params['breadcrumbs'][] = 'Update'; ?>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Image error display for me : https://im.ge/i/Uoauh [Controller] public function actionUpdate() { $searchModel = new RewardPercentSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); if (Yii::$app->request->post("hasEditable")) { $rewardPercent_id = Yii::$app->request->post('editableKey'); $model = LwRewardPercent::findOne($rewardPercent_id); $posted = current($_POST['LwRewardPercent']); $name_post_column = $_POST['editableAttribute']; $model->$name_post_column = $posted[$name_post_column];
Vỉew <?php
use common\models\LwRewardPercent; use yii\helpers\Html; use kartik\grid\GridView;
/ @var $this yii\web\View / / @var $searchModel common\models\RewardPercentSearch / / @var $dataProvider yii\data\ActiveDataProvider /
$this->title = ' '; $this->params['breadcrumbs'][] = ['label' => 'Reward Percent', 'url' => ['index']]; $this->params['breadcrumbs'][] = 'Update'; ?>
= Html::encode($this->title) ?>
$dataProvider, 'defaultPagination' => 'all', 'showPageSummary' => true, 'columns' => [ [ 'attribute' => 'id', 'pageSummary' => 'Total', 'vAlign' => 'center', 'width' => '210px', 'pageSummaryOptions' => ['colspan' => 3], ], [ 'attribute' => 'reward_key', 'pageSummary' => 'Total', 'label' => 'Reward Key', ], [ 'label' => 'Reward ', 'attribute' => 'reward_key', 'value' => function ($model) { return $model->rewardInfo->reward_name; }, ], [ 'class' => 'kartik\grid\EditableColumn', 'attribute' => 'percent', 'editableOptions' => [ 'header' => 'percent', 'inputType' => kartik\editable\Editable::INPUT_TEXT, 'options' => ['pluginOptions' => ['min' => 0, 'max' => 5000]], ], // 'hAlign' => 'right', 'vAlign' => 'middle', // 'width' => '200px', // 'format' => ['decimal', 2], 'pageSummary' => true ], [ 'class' => 'kartik\grid\EditableColumn', 'attribute' => 'reward_per_day', 'editableOptions' => [ // 'mode' => 'inline', 'header' => 'Reward per day', 'inputType' => kartik\editable\Editable::INPUT_SPIN, 'options' => ['pluginOptions' => ['min' => -1, 'max' => 5000]] ], // 'hAlign' => 'right', 'vAlign' => 'middle', 'width' => '300px', // 'format' => ['decimal', 0], ], ], ]); ?>