public static function checkQ() { $maxPub = Question::find()->max('publiced'); $tDay = 3600 * 24; // $maxPubNow = time() + $tDay * $maxPubNew = time() + Need::pro7gress('reserv') * $tDay; // User::per($maxPub, 'test', false); // User::per($maxPubNew, 'test', false); $cday = (int) round(($maxPubNew - $maxPub) / $tDay); // User::per($cday, 'cday', false); $res = Question::find()->where('npp=0')->orderBy('rand()')->limit($cday)->all(); // ->asArray() $count = 0; foreach ($res as $a) { $count++; $tmp = $maxPub + $tDay * $count; $a->publiced = $tmp; $maxNpp = Question::find()->max('npp'); $wday3 = Need::ua('wday3', getdate($tmp)['wday']); $a->user_take = Need::day2user($wday3); // User::per(User::day2user($wday3), 'wday3', false); $a->npp = $maxNpp + 1; $a->save(); // User::per($a->publiced, 'item: '.$a->id, false); } // User::per($res[0]->id, 'test', false); // die('--'); }
/*else if ($model->br_status == 'active') { return ['class' => 'success']; }*/ }, 'columns' => [['format' => 'raw', 'attribute' => 'npp', 'value' => function ($data) { $prefix = '#'; if ($data->npp < 10) { $prefix .= '00'; } else { if ($data->npp < 100) { $prefix .= '0'; } } return $prefix . $data->npp; }], 'publiced' => ['attribute' => 'publiced', 'label' => 'Дата', 'options' => ['style' => 'width: 75px'], 'format' => 'raw', 'value' => function ($data) { $date = getdate($data->publiced); return "<div class='pDate text-center'><div>{$date['mday']}-" . Need::ua('mon3', $date['mon']) . "</div><div>" . Need::ua('wday3', $date['wday']) . "</div></div>"; }], 'user_take' => ['label' => 'Автор відповіді', 'attribute' => 'user_take', 'options' => ['style' => 'min-width: 150px'], 'format' => 'raw', 'value' => function ($data) { $user = $data->doers; $res = '<span class="itUser"><a href="http://vk.com/id' . $user->vk_id . '" target="_blank"><img class="userAva thumbnail" src="' . Need::getAva($user) . '" /></a> <span class="userName">' . $user->username . '</span></span>'; if (Yii::$app->user->id == $data->user_take) { $res = '<strong>' . $res . '</strong>'; } return $res; }], ['attribute' => 'text', 'format' => 'raw', 'value' => function ($data) { //return Html::url('site/index'); if ($data->link) { return Html::a(Html::encode($data->text), $data->link, ['target' => '_blank']); // 'site/index' } else { return Html::encode($data->text); // Html::tag('p', Html::encode($data->text));