public function record() { $user = Yii::$app->session->get('user'); $service = new Service(); $service->userId = $user['userId']; $service->content = $this->content; $service->state = Service::STATE_UNREPLY; $service->createDate = DateFunctions::getCurrentDate(); if (!$service->save()) { throw new Exception("ConsultForm save error"); } }
/** * Finds the Service model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Service the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Service::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.')); } }
static function getPrice($example_id) { $services = Service::find()->innerJoinWith('example_service')->where(['example_service.example_id' => $example_id])->all(); //ExampleService::find()->where(['example_id' => $example_id])->all(); $price = 0; foreach ($services as $service) { $price += $service->price; } return $price; }
/** * Deletes an existing ServiceCategory model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $serviceService = Service::find()->andWhere(['category_id' => $id])->one(); if (null === $serviceService) { $this->findService($id)->delete(); } else { Yii::$app->session->setFlash('alert', ['body' => \Yii::t('backend', 'Can not delete category #' . $id . '. It used in other table. Change category for service #' . $serviceService->id . ' before delete.'), 'options' => ['class' => 'alert-error']]); } return $this->redirect(['index']); }
public function search($params) { $query = Service::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['Id' => $this->Id, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'IP', $this->IP])->andFilterWhere(['like', 'thumbnail', $this->thumbnail]); return $dataProvider; }
public function search($params) { $query = Service::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'type_id' => $this->type_id, 'organization_id' => $this->organization_id, 'price' => $this->price]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'code', $this->code]); return $dataProvider; }
/** * add photo to a set * @param $photoid */ protected function addPhotoToSet($photoid) { $flickr = Service::findOne('flickr-photo'); if ($flickr) { $client = $this->getFlickr(); $data = json_decode($flickr->data, true); if (!empty($data['photoset'])) { $params = ['method' => 'flickr.photosets.addPhoto', 'photoset_id' => $data['photoset'], 'photo_id' => $photoid]; $client->api('', 'POST', $params); } } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Service::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'order' => $this->order]); $query->andFilterWhere(['like', 'sid', $this->sid])->andFilterWhere(['like', 'header', $this->header])->andFilterWhere(['like', 'text', $this->text]); return $dataProvider; }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = Service::find(); if (!\Yii::$app->user->can('administrator')) { $query->forDomain(); } $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'author_id' => $this->author_id, 'category_id' => $this->category_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'domain_id' => $this->domain_id]); $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'price', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'before_body', $this->before_body])->andFilterWhere(['like', 'after_body', $this->after_body])->andFilterWhere(['like', 'on_scenario', $this->on_scenario]); return $dataProvider; }
/** * Updates an existing Example model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $model->attributes = array('service' => ExampleService::getExampleServices($id)); // Получаем список услуг компании $services = Service::getAllServices(); $post = Yii::$app->request->post(); //print_r(); if ($model->load(Yii::$app->request->post()) && $model->save(false)) { ExampleService::saveExampleServices($id, $post['Example']['service']); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model]); } }
public function actionView($sid) { $service = Service::find()->select('*')->innerJoinWith('secs')->where(['service.sid' => $sid])->one(); $page = Page::find()->where(['sid' => Yii::$app->controller->id])->select(['id', 'pid', 'sid', 'header'])->one(); $pages = Page::find()->select(['id', 'pid', 'sid', 'header'])->asArray()->indexBy('id')->all(); $mode = $pages[$page->id]; $branch[] = $mode; while (!is_null($mode['pid'])) { $mode = $pages[$mode['pid']]; $branch[] = $mode; } krsort($branch); $branch[] = ['header' => $service->header]; return $this->render('view', ['service' => $service, 'branch' => $branch]); }
/** * Lists all ServicePage models. * @return mixed */ public function actionIndex() { $searchModel = new ServicePageSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider->sort = ['defaultOrder' => ['published_at' => SORT_DESC]]; $dataProvider->query->andFilterWhere(['locale' => Yii::$app->language]); if (Yii::$app->request->get('mid')) { $parentModel = Service::find(['id' => Yii::$app->request->get('mid')])->one(); $parentModel = Service::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA', 'locale_group_id' => $parentModel->locale_group_id])->one(); $models = ServicePage::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA', 'service_id' => $parentModel->id])->all(); } else { $models = ServicePage::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA'])->all(); } $list = \yii\helpers\ArrayHelper::map($models, 'locale_group_id', 'title'); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'list' => $list]); }
/** * @return mixed */ protected function getFlickr() { $client = Yii::$app->authClientCollection->getClient('flickr-photo'); $flickr = Service::findOne('flickr-photo'); if ($flickr) { $data = json_decode($flickr->data); $token = new OAuthToken(['token' => $data->token, 'tokenSecret' => $data->tokenSecret]); $client->setAccessToken($token); /* test */ $r = $client->api('', 'GET', ['method' => 'flickr.test.login']); if ($r['stat'] == 'ok') { return $client; } return false; } return false; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Service::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'token', $this->token])->andFilterWhere(['like', 'data', $this->data]); //$query->andFilterWhere([ // 'DATE(FROM_UNIXTIME(`created_at`))' => $this->created_at, //]); return $dataProvider; }
/** * @inheritdoc * @return string */ public function run() { /* @var \common\components\FlickrPhoto $client */ $flickr = Service::findOne('flickr-photo'); if ($flickr) { $client = Yii::$app->authClientCollection->getClient('flickr-photo'); if ($client) { $data = json_decode($flickr->data); $token = new OAuthToken(['token' => $data->token, 'tokenSecret' => $data->tokenSecret]); $client->setAccessToken($token); /* test */ $r = $client->api('', 'GET', ['method' => 'flickr.test.login']); if ($r['stat'] == 'fail') { $this->alertError(); } else { return $this->render('flickr-upload-widget', ['client' => $client, 'flickr' => $flickr]); } } else { $this->alertError(); } } else { $this->alertError(); } }
<? use common\models\Service; use yii\helpers\Html; use yii\data\ActiveDataProvider; use yii\widgets\ListView; // Провайдер работ портфолио $services = array(); $services = Service::getExmapleServices($model->id); ///$m= array(); //print_r($services); // Обвертка элементов в тег $return = array(); for ($i=0;$i<count($services);$i++) { //foreach ($services as $service22){ $return[] = Html::tag('a', $services[$i]['title'], [ //'data-title'=>'Heading', 'data-content'=>$services[$i]['description'], //'data-toggle'=>'popover', 'data-trigger'=>'hover', 'data-placement'=>'bottom', 'role'=>'button', 'style'=>'text-decoration: underline; cursor:pointer;' ]); };
<? use yii\bootstrap\Tabs; use common\models\Service; // Услуги по данному примеру $services = Service::find()->where(['parent_id' => $model->service_id])->orderBy('sorting')->all(); // Определяем вкладки $all=' <div class="row"> <div class="col-md-4">'. $this->render("advantages/_advantage",["model" => $services[0] ]) .'</div> <div class="col-md-4">'. $this->render("advantages/_advantage",["model" => $services[2] ]) .'</div> <div class="col-md-4">'. $this->render("advantages/_advantage",["model" => $services[4] ]) .'</div> </div> <div class="row hidden-xs hidden-sm"> <div style="position:relative; top:35px; background: url(/image/shadow_ffffff_percent_50.png); z-index:2; height:20px;"></div> <div class="col-md-1 col-md-offset-1"><div class="arrow arrow-left bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-right bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-left bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-right bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-left bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-right bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-left bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-right bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-left bg-primary"></div></div> <div class="col-md-1"><div class="arrow arrow-right bg-primary"></div></div> </div>
/** * @return \yii\db\ActiveQuery */ public function getServices() { return $this->hasMany(Service::className(), ['type_id' => 'id']); }
public function actionSitemap() { $listtext = Text::find()->where(['on' => 1])->all(); $listservice = Service::find()->where(['on' => 1])->all(); return $this->render('sitemap', ['listtext' => $listtext, 'listservice' => $listservice]); }
public function afterDelete() { $service = Service::find()->andWhere(['locale_group_id' => $this->locale_group_id, 'domain_id' => Yii::$app->user->identity->domain_id])->one(); if ($service) { $service->delete(); } return parent::afterDelete(); }
/** * 查询发布的咨询,缓存1分钟 * @param null $limit * @return array|\yii\db\ActiveRecord[] */ public static function findPublished($limit = null) { if ($limit) { return Service::getDb()->cache(function () use($limit) { return Service::find()->where(['state' => Service::STATE_PUBLISH])->limit($limit)->orderBy(['replyDate' => SORT_DESC])->all(); }, 60); } else { return Service::getDb()->cache(function () { return Service::find()->where(['state' => Service::STATE_PUBLISH])->orderBy(['replyDate' => SORT_DESC])->all(); }, 60); } }
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use common\models\Service; use common\models\Type; $types = ArrayHelper::map(Type::find()->asArray()->all(), 'type_id', 'title'); $services = ArrayHelper::map(Service::find()->where(['parent_id' => 0])->asArray()->all(), 'id', 'title'); ?> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <div class="row"> <div class="col-md-4"> <?php echo $form->field($model, 'landing_id')->textInput(['readonly' => true]); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'type_id')->dropDownList($types); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'service_id')->dropDownList($services); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getService() { return $this->hasOne(Service::className(), ['id' => 'service_id']); }
$form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'service_id')->dropDownList(ArrayHelper::map(Service::find()->where(['parent_id' => 0])->asArray()->all(), 'id', 'title')); ?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'service')->checkboxList(ArrayHelper::map(Service::find()->all(), 'id', 'title')); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
<? use common\models\Service; use yii\widgets\ListView; use yii\data\ActiveDataProvider; // Топ сервисы $all = new ActiveDataProvider([ 'query' => Service::getTopServices(), 'pagination' => [ 'pageSize' => 100, ], ]); ?> <div id="service_version_1" class="block"> <div class="container"> <div class="jumbotron text-center"> <h2><?php echo $model->title; ?> </h2> <p><?php echo $model->description; ?> </p> </div>
<? use yii\helpers\Html; use common\models\Service; // Получаем подуслуги $services = Service::getArrayServices($model->id); ?> <div class="panel panel-primary"> <div class="panel-heading"> <p class="panel-title"><?php echo $model->title; ?> </p> </div> <div class="list-group"> <? foreach ($services as $service): ?> <button type="button" class="list-group-item"><? if($service->icon) echo '<i class="fa fa-'.$service->icon.'"></i> '?><?php echo $service->title; ?> </button> <? endforeach; ?> </div> </div>
// Если пример определен if ($example_id) { // Услуги по данному примеру $services = Service::getExmapleServices($example_id); $example = Example::findOne($example_id); } // Если услуга определена if ($service_id) { // Услуги по данному примеру $service = Service::findOne($service_id); } // Решения по услуге "создание сайтов" (1) $examples = Example::find()->where(['service_id' => $model->service_id])->all(); ?> <?php \yii\widgets\Pjax::begin(); ?> <div id="example_version_1"> <div class="container"> <div class="container_header"> <div class="jumbotron text-center">
/** * Finds the Service model based on its primary key value. * If the service is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Service the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findService($id) { if (($service = Service::findOne($id)) !== null) { return $service; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionPublish() { $request = Yii::$app->request; if ($request->isPost) { $serviceId = $request->post('serviceId'); return Service::changePublish($serviceId); } else { CommonFunctions::createAlertMessage("非正常请求,错误!", 'error'); } return $this->redirect(['service/index']); }
/** * @inheritdoc */ static function getTopServices($parent_id = 0) { $models = Service::find()->where(['parent_id' => $parent_id])->orderBy(['sorting' => SORT_ASC]); return $models; }