1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace manager\controllers;
- use \app\models\Nh;
- use \app\models\Kd;
- use \app\models\News;
- use Yii;
- class NhController extends BaseController
- {
- public function actionIndex()
- {
- $model = new Kd();
- $modelnh = new Nh();
- return $this->render('/kd/nh', ['model' => $model,'modelnh' => $modelnh]);
- }
- public function actionFix($id)
- {
- $model = new Kd();
- $modelnh = new Nh();
- $nmodel = News::findone($id);
- if( $nmodel->NH == 'Y' ){
- $nmodel->NH($id,'F');
- }else{
- $nmodel->NH($id,'Y');
- }
- return $this->render('/kd/nh', ['model' => $model,'modelnh' => $modelnh]);
- }
- public function actionDel($id)
- {
- $model = new Kd();
- $modelnh = new Nh();
- $nmodel = News::findone($id);
- $nmodel->NH($id,'N');
- return $this->render('/kd/nh', ['model' => $model,'modelnh' => $modelnh]);
- }
- public function actionPreview()
- {
- $model = new Kd();
- $modelnh = new Nh();
- return $this->renderPartial('/kd/actionPreview', ['model' => $model,'modelnh' => $modelnh]);
- }
- public function actionSort()
- {
- if (isset($_GET['item']) && is_array($_GET['item'])) {
- $i = 0;
- $a = array();
-
- foreach ($_GET['item'] as $item) {
- if( $item > 0 ){
- $model = Nh::findone(['id'=>$item]);
- if($model == false){
- $model = new Nh();
- $model->id = $item;
- }
- $model->order = $i;
- $a[$model->id] = $i;
-
- $model->save(true, ['order','id']);
- }
- $i++;
- if( $i > 5 ) break;
- }
- return json_encode(['status'=>'ok','data'=>$a]);
- }
- return json_encode(['status'=>'err']);
- }
- }
|