public function actionIndex() { $productModel = new MirProduct(); $list = $productModel->mainClass(); p($list); return $this->render('index'); }
public function actionIndex() { //友情链接 $friendLink = new FriendLink(); $friendLinks = $friendLink->getFriendLinks(); $num = ceil(count($friendLinks) / 8); for ($i = 0; $i < count($friendLinks); $i++) { $newFriendLinks[floor($i / 8)][] = $friendLinks[$i]; } // p($newFriendLinks[0][1]); //学术会议和展览展会 $meetingModel = new MirMeeting(); $xueshuMeetings = $meetingModel->find()->select("meeting_id,meeting_name,meeting_bdate")->where(["meeting_class" => '1'])->orderBy('meeting_id desc')->limit(5)->all(); $zhanhuiMeetings = $meetingModel->find()->select("meeting_id,meeting_name,meeting_bdate")->where(["meeting_class" => '2'])->orderBy('meeting_id desc')->limit(5)->all(); $meetingModel = new MirMeeting(); //新闻中心 $articleModel = new MirArticle(); $news = $articleModel->articleToIndex(0); //招标公告 $zhaobiao = $articleModel->articleToIndex(2); //技术分享 $jishus = $articleModel->articleToIndex(3); // p($zhaobiao); //临床医学 $ivdModel = new MirIvd(); $linchuangyixues = $ivdModel->getIvdlist(3); $pinpaililiang = $ivdModel->getIvdlist(1); $zhutizhuanfang = $ivdModel->getIvdlist(2); $zhuanjiazhuanlan = $ivdModel->getIvdlist(4); // p($linchuangyixues); // 把主题专访 四个合并成一个 $firstData[] = $linchuangyixues; $firstData[] = $zhutizhuanfang; $firstData[] = $zhuanjiazhuanlan; $firstData[] = $pinpaililiang; // p($firstData); // p($linchuangyixues); // IVD展厅 $porduct = new MirProduct(); $porducts = MirProduct::find()->orderBy("product_id desc")->limit(5)->all(); // p($porducts[0]->product_pic); //索刊 $mgzModel = new MirMgz(); $mgz = $mgzModel->find()->orderBy("mgz_id desc")->groupBy("mgz_year,mgz_num")->all(); for ($i = 0; $i < count($mgz); $i++) { $mgzYear[] = $mgz[$i]->mgz_year; $mgzNum[] = $mgz[$i]->mgz_num; } $fourPic = $porduct->find()->andWhere(["!=", "product_pic", "productnopic.gif"])->orderBy("product_id desc")->limit(4)->all(); // p($fourPic); //获得视屏中心的照片 $videoModel = new MirVideo(); $videos = $videoModel->find()->orderBy("video_id desc")->all(); return $this->render('index', ['newFriendLinks' => $newFriendLinks, 'zhanhuiMeetings' => $zhanhuiMeetings, 'xueshuMeetings' => $xueshuMeetings, 'news' => $news, 'zhaobiao' => $zhaobiao, 'jishus' => $jishus, 'firstData' => $firstData, 'porducts' => $porducts, 'mgzYear' => $mgzYear, 'mgzNum' => $mgzNum, 'fourPic' => $fourPic, 'videos' => $videos]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { /** * 根据参数选择展示的商品 * @var dis=>1 不现实的 0=>显示的 */ $display = Yii::$app->request->get('dis'); $map = ['product_disp' => $display]; $query = MirProduct::find()->where($map); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['product_id' => $this->product_id, 'product_price' => $this->product_price, 'product_disp' => $this->product_disp, 'product_rank' => $this->product_rank]); $query->andFilterWhere(['like', 'product_name', $this->product_name])->andFilterWhere(['like', 'product_name_e', $this->product_name_e])->andFilterWhere(['like', 'product_date', $this->product_date])->andFilterWhere(['like', 'product_class', $this->product_class])->andFilterWhere(['like', 'product_place', $this->product_place])->andFilterWhere(['like', 'product_place_e', $this->product_place_e])->andFilterWhere(['like', 'product_standards', $this->product_standards])->andFilterWhere(['like', 'product_standards_e', $this->product_standards_e])->andFilterWhere(['like', 'product_model', $this->product_model])->andFilterWhere(['like', 'product_model_e', $this->product_model_e])->andFilterWhere(['like', 'product_performance', $this->product_performance])->andFilterWhere(['like', 'product_performance_e', $this->product_performance_e])->andFilterWhere(['like', 'product_parameter', $this->product_parameter])->andFilterWhere(['like', 'product_parameter_e', $this->product_parameter_e])->andFilterWhere(['like', 'product_contrast', $this->product_contrast])->andFilterWhere(['like', 'product_contrast_e', $this->product_contrast_e])->andFilterWhere(['like', 'product_appraise', $this->product_appraise])->andFilterWhere(['like', 'product_appraise_e', $this->product_appraise_e])->andFilterWhere(['like', 'product_pic', $this->product_pic])->andFilterWhere(['like', 'product_mainclass', $this->product_mainclass])->andFilterWhere(['like', 'product_brand', $this->product_brand])->andFilterWhere(['like', 'product_tui', $this->product_tui])->andFilterWhere(['in', 'product_maker', $this->product_maker]); return $dataProvider; }
/** * 到达产品详情页面 * @AuthorHTL * @DateTime 2016-01-12T17:21:01+0800 * @return [type] [description] */ public function actionIndex3() { $id = Yii::$app->request->get("id"); $model = MirProduct::findOne(["product_id" => $id]); // p($model); return $this->render('index3', ['model' => $model]); }
<?php echo $form->field($model, 'product_rank')->textInput(['placeholder' => '产品排序序号,用户前端显示']); ?> <?php echo $form->field($model, 'product_pic')->textInput(['id' => 'pic', 'readonly' => true]); ?> <?php echo Uploadify::widget(['targetId' => 'pic', 'multi' => 'false', 'classify' => 'product']); ?> <div class="col-lg-6 row"> <?php echo $form->field($model, 'product_place')->dropDownList(MirProduct::cityMap(), ['prompt' => '请选择', 'onchange' => 'getCityEnglish(' . '$(this).val()' . ')']); ?> </div> <div class="col-lg-7 row"> <?php echo $form->field($model, 'product_place_e')->textInput(['readonly' => true, 'style' => 'margin-left:15px', 'id' => 'product_e']); ?> </div> </div> <div class="col-lg-12"> <div class="col-lg-6 row"> <?php echo $form->field($model, 'product_standards')->textarea(['rows' => 6]); ?> </div> <div class="col-lg-6 row">
echo Html::encode($this->title); ?> </h1> <div class="row"> <div class="col-lg-12"> <div class="panel panel-default"> <div class="panel-heading"></div> <div class="panel-body"> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'product_id', 'headerOptions' => ['width' => '80']], 'product_name', ['attribute' => 'product_maker', 'value' => function ($data) { return MirProduct::makerMap($data->product_maker); }], ['attribute' => 'product_pic', 'format' => 'raw', 'value' => function ($data) { /** 图片链接待确定 */ return Html::img(Yii::getAlias('@uploads') . "/pro/" . $data->product_pic, ['width' => '172', 'height' => '56']); }], ['attribute' => 'product_date', 'value' => function ($data) { return date('Y/m/d', strtotime($data->product_date)); }], ['attribute' => 'product_rank', 'headerOptions' => ['width' => 50]], ['attribute' => 'product_mainclass', 'headerOptions' => ['width' => 90], 'filter' => $mainClass, 'value' => function ($data) { $classify = Classify::mainClass(); if ($data->product_mainclass == 0) { return $classify[$data->ID]; } else { return $classify[$data->product_mainclass]; } }], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'template' => '{view} {update} {delete}', 'headerOptions' => ['width' => '100']]]]); ?>
/** * Finds the MirProduct model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MirProduct the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MirProduct::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }