public function safeUp() { $this->addColumn('{{%object_cbs}}', 'id', Schema::TYPE_PK); $this->addColumn('{{%object_cbs}}', 'created_at', Schema::TYPE_INTEGER . ' NOT NULL'); $this->addColumn('{{%object_cbs}}', 'updated_at', Schema::TYPE_INTEGER . ' NOT NULL'); $query = \app\models\Objects::find(); $query->where(['not', ['cbs' => null]]); $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query]); $objectsArray = $dataProvider->getModels(); foreach ($objectsArray as $objects) { $cbsNames = explode(',', $objects->cbs); foreach ($cbsNames as $cbsName) { // Find the CBS from APIs that matches the name that was saved as a text before $cbs = \app\models\Apis::findOne(['name' => $cbsName]); if ($cbs) { $objectsCBS = new \app\models\ObjectCBS(); $objectsCBS->object = $objects->id; $objectsCBS->cbs = $cbs->id; $objectsCBS->save(); } } } // Drop column cbs from Objects Table that is not needed anymore $this->dropColumn('{{%objects}}', 'cbs'); }
public function actionPhotos($album_id) { $pageSize = 11; $photos = \app\modules\photo\models\Photos::find()->where('is_deleted=0 AND album_id=:album_id', [':album_id' => $album_id]); $provider = new \yii\data\ActiveDataProvider(['query' => $photos, 'pagination' => ['pageSize' => $pageSize]]); $totalCount = $provider->getTotalCount(); $totalPageCount = (int) ($totalCount / $pageSize + 1); if ($totalPageCount < filter_input(INPUT_GET, 'page')) { exit; } $array = array(); foreach ($provider->getModels() as $model) { $array[] = $model->attributes; } Yii::$app->response->format = 'json'; return $array; }
public function actionIndex($count = DEFAULT_PAGE_SIZE) { if (Yii::$app->request->isAjax) { Yii::$app->controller->module->layout = false; } $where_clause = null; if (isset(\Yii::$app->controller->searchFields)) { $argument_data = null; if (Yii::$app->request->isAjax) { $argument_data = $_REQUEST; } $where_clause = \vendor\codefire\cfusermgmt\models\Behavior\searchBehavior::search_behavior($argument_data); } $query = Setting::find()->where($where_clause); $activeDataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $count], 'sort' => ['defaultOrder' => ['id' => SORT_DESC], 'attributes' => ['created', 'id', 'name_public', 'value']]]); // echo "<pre>";print_r($query);die; $models = $activeDataProvider->getModels(); return $this->render('index', ['activeDataProvider' => $activeDataProvider, 'models' => $models]); }
public function actionIndex($count = DEFAULT_PAGE_SIZE) { if (Yii::$app->request->isAjax) { Yii::$app->controller->module->layout = false; } $where_clause = null; if (isset(\Yii::$app->controller->searchFields)) { $argument_data = null; if (Yii::$app->request->isAjax) { $argument_data = $_REQUEST; } $where_clause = \vendor\codefire\cfusermgmt\models\Behavior\searchBehavior::search_behavior($argument_data); } $query = RoleAndPermission::find()->onCondition(['type' => TYPE_ROLE])->where($where_clause); //Type 1 is for Role (Type 2 is for permission); $activeDataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $count], 'sort' => ['defaultOrder' => ['name' => SORT_DESC], 'attributes' => ['created_at', 'name', 'role_alias', 'allow_registration']]]); $models = $activeDataProvider->getModels(); return $this->render('index', ['activeDataProvider' => $activeDataProvider, 'models' => $models]); }
public function search($params) { $query = self::find()->joinWith(['author']); $query->all(); $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['attributes' => ['id', 'name', 'author_id' => ['asc' => ['firstname' => SORT_ASC, 'lastname' => SORT_ASC], 'desc' => ['firstname' => SORT_DESC, 'lastname' => SORT_DESC], 'default' => SORT_ASC], 'date', 'date_create']]); if ($params->author_id) { $query->andFilterWhere(['author_id' => $params->author_id]); } if ($params->name) { $query->andFilterWhere(['like', 'name', $params->name]); } if ($params->fromDate && $params->toDate) { $fromDate = split('/', $params->fromDate); $fromDate = $fromDate[2] . '-' . $fromDate[1] . '-' . $fromDate[0]; $toDate = split('/', $params->toDate); $toDate = $toDate[2] . '-' . $toDate[1] . '-' . $toDate[0]; $query->andFilterWhere(['between', 'date', $fromDate, $toDate]); } return $dataProvider; }
/** * Function for locality auto suggestion */ public function actionAutosuggest() { Yii::$app->response->format = Response::FORMAT_JSON; $request = Yii::$app->request->post(); list($city) = $request['depdrop_parents']; $query = BrandsCityMap::find()->where('status=1'); if (!empty($city)) { if ($city) { $query->andFilterWhere(['cityId' => $city]); } } $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => false]); $data = []; //$data[] = ['id'=>0, 'name' => 'Select Brand']; foreach ($dataProvider->getModels() as $model) { $data[] = ['id' => $model->Id, 'name' => $model->chain->name]; } return ['output' => $data]; }
public function actionOnline($count = DEFAULT_PAGE_SIZE) { if (Yii::$app->request->isAjax) { Yii::$app->controller->module->layout = false; } $where_clause = null; if (isset(\Yii::$app->controller->searchFields)) { $argument_data = null; if (Yii::$app->request->isAjax) { $argument_data = $_REQUEST; } $where_clause = searchBehavior::search_behavior($argument_data); } $query = UserActivity::find()->where($where_clause); $activeDataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $count], 'sort' => ['defaultOrder' => ['created' => SORT_DESC], 'attributes' => ['created', 'id', 'name', 'email', 'username']]]); $models = $activeDataProvider->getModels(); return $this->render('online', ['activeDataProvider' => $activeDataProvider, 'models' => $models]); }
public function actionAutosuggestion($search = null) { Yii::$app->response->format = Response::FORMAT_JSON; $query = \common\models\Restaurant::find(); if ($search) { $query->andFilterWhere(['like', 'name', $search . '%', false]); } //*/ $query->andFilterWhere(['status' => \common\component\AppActiveRecord::STATUS_PUBLISH]); //*/ $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query]); $data = []; foreach ($dataProvider->getModels() as $model) { $NameString = $model->Id . ' - ' . $model->name . ' in ' . $model->localityname . ' ' . $model->cityname . ' (' . $model->zonename . ')'; //$NameString = (string)$model->Id; $data[] = ['id' => $model->Id, 'text' => $NameString]; } return $data; }
public function actionFilter() { $searchModel = new MenuSearch(); // // $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $menuList = Menu::find()->where(['uid' => Yii::$app->user->getId()])->leftJoin('{{%plug}}', '{{%plug}}.id={{%menu}}.type')->select('{{%menu}}.*,{{%plug}}.name as typename,{{%plug}}.controller as controller')->orderBy('sort_order')->andFilterWhere(['{{%menu}}.type' => Yii::$app->request->get('filtertype')])->andFilterWhere(['{{%menu}}.title' => Yii::$app->request->get('filtertitle')]); $dataProvider = new \yii\data\ActiveDataProvider(['query' => $menuList, 'pagination' => ['pageSize' => 20], 'sort' => ['defaultOrder' => ['id' => SORT_ASC, 'sort_order' => SORT_DESC]]]); $posts = $dataProvider->getModels(); UHelper::output($posts); return $this->render('filter', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'pluglist' => self::plugList()]); }
No.Faktur:<?php echo ' ' . $model->number; ?> <br> Tgl:<?php echo ' ' . date('d-m-Y H:i:s', $model->created_at); ?> Kasir:<?php echo ' ' . $model->kasir->username; ?> </p> <?php $totaLine = 0; $totalDiskon = 0; $dtPro = new yii\data\ActiveDataProvider(['query' => $model->getItems()->with(['product', 'uom']), 'pagination' => false, 'sort' => false]); if (!empty($dtPro->getModels())) { echo Html::beginTag('table', ['style' => 'width:100%; border-top:1px dotted #000;']); foreach ($dtPro->getModels() as $key => $val) { $b4diskon = $val->price * $val->qty * $val->productUom->isi; $afdiskon = $b4diskon * (1 - $val->discount / 100); $diskon = $b4diskon - $afdiskon; $totaLine += $afdiskon; $totalDiskon += $b4diskon - $afdiskon; $split = explode(';', $val->product->name); $newname = $split[1] . ';' . $split[2] . ';' . $split[0]; $dname = strlen($newname) > 21 ? substr($newname, 0, 21) : $newname; echo Html::beginTag('tr'); echo Html::tag('td', $val->qty . $val->uom->code, ['style' => 'height:2px; padding-right:5px;']); echo Html::tag('td', $dname); echo Html::tag('td', number_format($val->price * $val->qty * $val->productUom->isi, 0), ['style' => 'text-align:right;']);
/** * * @param string $q * @return JSON encoded associative array of suggested venue * @author Atul */ public function actionFetchVenue($q = null, $cityId = 0, $type = 0) { Yii::$app->response->format = Response::FORMAT_JSON; if ($type == 0) { $query = Restaurant::find()->with('city', 'locality', 'zone'); } else { $query = \common\models\Venue::find()->with('city', 'locality', 'zone'); } if (!empty($cityId)) { if ($cityId) { $query->andFilterWhere(['cityId' => $cityId]); } if ($q) { $query->andFilterWhere(['like', 'name', $q . '%', false]); } //*/ $query->andFilterWhere(['status' => \common\component\AppActiveRecord::STATUS_PUBLISH]); //*/ $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query]); $data = []; foreach ($dataProvider->getModels() as $model) { $NameString = $model->name . ' in ' . $model->localityname . ' ' . $model->cityname . '(' . $model->zonename . ')'; $data[] = ['id' => $model->Id, 'value' => $NameString]; } return $data; } }