/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $this->scenario = 'search'; $query = Document::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]); $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, 'lft' => $this->lft, 'rgt' => $this->rgt, 'depth' => $this->depth, 'template_id' => $this->template_id, 'is_folder' => $this->is_folder, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'created_user_name', $this->created_user_name])->andFilterWhere(['like', 'updated_user_name', $this->updated_user_name])->andFilterWhere(['like', 'root_name', $this->root_name])->andFilterWhere(['like', 'parent_name', $this->parent_name])->andFilterWhere(['like', 'created_at', CFF::FormatData($this->created_at)])->andFilterWhere(['like', 'updated_at', CFF::FormatData($this->updated_at)])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'annotation', $this->annotation])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'img', $this->img])->andFilterWhere(['like', 'meta_description', $this->meta_description])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['>=', 'id', $this->id_from])->andFilterWhere(['<=', 'id', $this->id_till])->andFilterWhere(['<>', 'id', 1]); for ($i = 1; $i <= Template::OPTIONS_COUNT; $i++) { $option = 'option_' . $i; $query->andFilterWhere(['like', $option, $this->{$option}]); } if ($this->created_at_from) { $query->andFilterWhere(['>=', 'created_at', CFF::FormatData($this->created_at_from, false) . ' 00:00:00']); } if ($this->created_at_till) { $query->andFilterWhere(['<=', 'created_at', CFF::FormatData($this->created_at_till, false) . ' 23:59:00']); } if ($this->updated_at_from) { $query->andFilterWhere(['>=', 'updated_at', CFF::FormatData($this->updated_at_from, false) . ' 00:00:00']); } if ($this->updated_at_till) { $query->andFilterWhere(['<=', 'updated_at', CFF::FormatData($this->updated_at_till, false) . ' 23:59:00']); } return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Document::find(); $userlname = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'userLName'); $userfname = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'userFName'); $userfullname = $userlname . ', ' . $userfname; $docname = ArrayHelper::getValue(Pendingdoc::find()->where(['pendingDocFName' => $userfullname])->one(), 'pendingDocName'); //$docname = Pendingdoc::find()->where(['pendingDocFName' => $userfullname])->one(); //$docname = 1; $userid = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'id'); //$query->where(['or', ['documentName'=>$docname], ['user_id'=>$userid]]); //$query->where(['INNER JOIN', 'Pendingdoc', 'Pendingdoc.pendingDocName = documentName']); $query->join('LEFT JOIN', 'pendingdoc', 'document.documentName = pendingdoc.pendingDocName')->where(['or', ['pendingdoc.pendingDocFName' => $userfullname], ['user_id' => $userid]]); $dataProvider = new ActiveDataProvider(['query' => $query]); $query->joinWith('priority'); $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(['documentTargetDate' => $this->documentTargetDate, 'category_id' => $this->category_id, 'type_id' => $this->type_id, 'user_id' => $this->user_id, 'companyAgency_id' => $this->companyAgency_id, 'section_id' => $this->section_id, 'documentCreate' => $this->documentCreate, 'documentUpdate' => $this->documentUpdate]); $query->andFilterWhere(['like', 'document_tracking_number', $this->document_tracking_number])->andFilterWhere(['like', 'documentName', $this->documentName])->andFilterWhere(['like', 'documentDesc', $this->documentDesc])->andFilterWhere(['like', 'documentComment', $this->documentComment])->andFilterWhere(['like', 'documentImage', $this->documentImage])->andFilterWhere(['like', 'document.id', $this->id])->andFilterWhere(['like', 'priority.priorityName', $this->priority_id]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Document::find()->byResearch(); $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; } $query->andFilterWhere(['id' => $this->id, 'research_id' => $this->research_id, 'document_type_id' => $this->document_type_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'filename', $this->filename])->andFilterWhere(['like', 'real_filename', $this->real_filename])->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
private static function _entityDecoder($attributes) { /* check social facebook instagram twitter */ $itemNo = NULL; switch ($attributes['type']) { case 'document': $itemNo = $attributes['itemno']; $entityType = Entity::mapType($attributes['type']); $entity = Document::findOne(['type' => 5, 'refId' => $attributes['id'], 'itemNo' => $itemNo]); break; default: $entityType = Entity::mapType($attributes['type']); $entity = Entity::getInstance($entityType, $attributes['id']); break; } if (empty($entity)) { return; } switch ($attributes['type']) { case 'document': $arr = explode(".", $entity->srcPath); $extension = $arr[count($arr) - 1]; $thumbnail = $extension . ".png"; $thumbnailUrl = Url::toRoute(['/global/img/' . $thumbnail]); $str = "<entity type=\"{$attributes['type']}\" data-itemno=\"{$attributes['itemno']}\" data-id=\"{$attributes['id']}\">"; $str .= '<img src="' . $thumbnailUrl . '" alt="" width="30" height="30">'; break; default: $str = "<entity type=\"{$attributes['type']}\" data-id=\"{$attributes['id']}\">" . $entity->getPreview(array(Media::ENCODE_WIDTH => 100)); break; } switch ($entityType) { case Entity::TYPE_PERSON: $caption = $entity->getDisplayName(); break; case Entity::TYPE_DOCUMENT: $caption = $entity->caption; break; default: $caption = $entity->title; } $str .= "<p class=\"caption\">" . Entity::$arrTitle[$entityType] . ": {$caption}</p></entity>"; return $str; }
/** * ให้ค่า instance ของ model ที่ระบุด้วย entity type และ $refId * @param int $type * @param int $refId * @return ActiveRecord */ public static function getInstance($type, $refId, $orderNo = NULL) { $instance = null; switch ($type) { case self::TYPE_ACTIVITY: $instance = Activity::findOne($refId); break; case self::TYPE_BLOG: $instance = Blogs::findOne($refId); break; case self::TYPE_CARTOON: $arr = preg_split('/-/', $refId); $instance = CartoonChapter::findOne(array('cartoonId' => $arr[0], 'chapter' => $arr[1])); break; case self::TYPE_CONTENT: $instance = Content::findOne($refId); break; case self::TYPE_DOCUMENT: $instance = Document::findOne(array('type' => $type, 'refId' => $refId, 'itemNo' => $orderNo)); break; case self::TYPE_FAQ: $instance = Faq::findOne($refId); break; case self::TYPE_FEEDCONTENT: $instance = FeedContent::findOne($refId); break; case self::TYPE_FEED: $instance = Feed::findOne($refId); break; case self::TYPE_GALLERY: $instance = Gallery::findOne($refId); break; case self::TYPE_INFOGRAPHIC: $instance = InfoGraphic::findOne($refId); break; case self::TYPE_LIVEREPORT: $instance = LiveReport::findOne($refId); break; case self::TYPE_LOTTERY: $instance = Lottery::findOne($refId); break; case self::TYPE_BUNNY: case self::TYPE_MEDIA_COLLECTION: $instance = MediaCollection::findOne($refId); break; case self::TYPE_NEWSPAPER: // temporary class for media upload $instance = new stdClass(); $instance->createTime = date('Y-m-d H:i:s'); break; case self::TYPE_NOVEL: $instance = Novel::findOne($refId); break; case self::TYPE_PERSON: $instance = Person::findOne($refId); break; case self::TYPE_SPORT_PLAYER: $instance = Player::findOne($refId); break; case self::TYPE_SPORT_TEAM: $instance = Team::findOne($refId); break; case self::TYPE_QUOTE: $instance = Quote::findOne($refId); break; case self::TYPE_WIDGET: $instance = Widget::findOne($refId); break; case self::TYPE_TV_ANCHOR: $instance = TvAnchor::findOne($refId); break; case self::TYPE_TV_PROGRAM: $instance = TvProgram::findOne($refId); break; case self::TYPE_TV_HIGHLIGHT: $instance = TvHighlight::findOne($refId); break; case self::TYPE_TV_SCHEDULE: $instance = TvSchedule::findOne($refId); break; case self::TYPE_USER: $instance = User::findOne($refId); break; case self::TYPE_VIDEO: $instance = Video::findOne($refId); break; case self::TYPE_VIDEO_PLAYLIST: $instance = VideoPlaylist::findOne($refId); break; case self::TYPE_WATCHTOPIC: $instance = WatchTopic::findOne($refId); break; case self::TYPE_WEATHER: $instance = WeatherForecast::findOne($refId); break; } return $instance; }
/** * @return \yii\db\ActiveQuery */ public function getDocuments() { return @$this->hasMany(Document::className(), ['research_id' => 'id']); }
/** * ดึงข้อมูลจาก model ที่ระบุด้วย $params * @param array $params เงื่อนไขการดึงข้อมูล * @return Document */ public function findByParams($params) { $query = Document::find(); $query->where(['type' => $params[self::ENCODE_ENTITY], 'refId' => $params[self::ENCODE_ID], 'itemNo' => $params[self::ENCODE_ITEMNO]]); $model = $query->one(); return $model; }
/** * @return \yii\db\ActiveQuery */ public function getDocuments() { return $this->hasMany(Document::className(), ['companyAgency_id' => 'id']); }
<?php Modal::begin(['header' => '<h4>Documents</h4>', 'id' => 'modal']); echo "<div id='modalContent'></div>"; Modal::end(); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'document_tracking_number', 'documentName', 'documentDesc', ['attribute' => 'priority_id', 'value' => 'priority.priorityName'], ['attribute' => 'Duration', 'format' => 'raw', 'value' => function ($model) { $position = Yii::$app->user->identity->position_id; //$today = date('Y-m-d H:i:s'); $today = null; //$today = ArrayHelper::getValue(Docworkflow::find()->where(['document_id' => $model->id])->orderBy(['id'=>SORT_DESC])->one(), 'timeAccepted'); $today = ArrayHelper::getValue(Document::find()->where(['id' => $model->id])->one(), 'documentUpdate'); if ($today == null) { $today = ArrayHelper::getValue(Document::find()->where(['id' => $model->id])->one(), 'documentCreate'); } if ($position == 21 || $position == 22 || $position == 23 || $position == 24 || $position == 25 || $position == 26) { if ($model->priority->priorityName == 'Urgent') { $now = date('Y-m-d H:i:s', strtotime("{$today} + 8 hours")); } else { if ($model->priority->priorityName == 'High') { $now = date('Y-m-d H:i:s', strtotime("{$today} + 3 days")); } else { if ($model->priority->priorityName == 'Medium') { $now = date('Y-m-d H:i:s', strtotime("{$today} + 5 days")); } else { if ($model->priority->priorityName == 'Low') { $now = date('Y-m-d H:i:s', strtotime("{$today} + 7 days")); } }
protected function createDocument($research_id) { $documentTypes = DocumentType::find()->all(); foreach ($documentTypes as $doc) { $model = Yii::createObject(['class' => Document::className(), 'research_id' => $research_id, 'document_type_id' => $doc->id]); $model->save(); unset($model); } }
</div> <div class="col-sm-6"> <?php echo $form->field($model, 'created_ip')->textInput(['maxlength' => true]); ?> </div> </div> <div class="row"> <div class="col-sm-6"> <?php echo $form->field($model, 'for_user_id')->widget(Select2::classname(), ['language' => 'ru', 'data' => User::getAll(), 'options' => ['placeholder' => '', 'id' => 'for_user_id'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-sm-6"> <?php echo $form->field($model, 'for_document_id')->widget(Select2::classname(), ['language' => 'ru', 'data' => Document::getAll(), 'options' => ['placeholder' => '', 'id' => 'for_document_id'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> </div> <div class="row"> <div class="col-sm-6"> <?php echo $form->field($model, 'parent_message_id')->textInput(['maxlength' => true]); ?> </div> <?php for ($i = 1; $i <= Message::OPTIONS_COUNT; $i++) { echo "<div class='col-sm-6'>" . $form->field($model, 'option_' . $i)->textInput(['maxlength' => true]) . "</div>"; } ?> </div>
echo Html::submitButton('<span class="glyphicon glyphicon-search"></span> Найти', ['class' => 'btn btn-primary']); ?> <?php echo Html::a('<span class="glyphicon glyphicon-repeat"></span> Сбросить', ['/document'], ['class' => 'btn btn-default']); ?> </div> <div class="row"> <div class="col-sm-6"> <?php echo FieldRange::widget(['form' => $form, 'model' => $model, 'label' => 'ID', 'separator' => 'от ... до', 'attribute1' => 'id_from', 'attribute2' => 'id_till', 'type' => FieldRange::INPUT_TEXT]); ?> </div> <div class="col-sm-6"> <?php echo $form->field($model, 'status')->widget(Select2::classname(), ['language' => 'ru', 'data' => Document::getStatuses(), 'options' => ['placeholder' => ''], 'pluginOptions' => ['allowClear' => true]]); ?> </div> </div> <div class="row"> <div class="col-sm-6"> <?php echo FieldRange::widget(['form' => $form, 'model' => $model, 'label' => 'Дата создания', 'separator' => 'от ... до', 'attribute1' => 'created_at_from', 'attribute2' => 'created_at_till', 'type' => FieldRange::INPUT_DATETIME]); ?> </div> <div class="col-sm-6"> <?php echo FieldRange::widget(['form' => $form, 'model' => $model, 'label' => 'Дата обновления', 'separator' => 'от ... до', 'attribute1' => 'updated_at_from', 'attribute2' => 'updated_at_till', 'type' => FieldRange::INPUT_DATETIME]); ?> </div> </div>
case 5: // Текст echo "<div class='{$class}'><div>" . Html::activeLabel($model, $option, ['class' => 'control-label']) . "</div><div>" . Html::activeTextarea($model, $option, $options_attributes) . "</div><div class='help-block'>" . $error . "</div></div>"; break; case 6: // Файл (выбор) echo "<div class='{$class}'><div>" . Html::activeLabel($model, $option, ['class' => 'control-label']) . "</div><div>" . InputFile::widget(['language' => 'ru', 'controller' => 'elfinder', 'filter' => 'image', 'template' => '<div class="input-group"> {input}<span class="input-group-btn">{button}</span> </div>', 'options' => $options_attributes, 'buttonOptions' => ['class' => 'btn btn-default'], 'buttonName' => 'Выбрать файл', 'name' => 'Document[option_' . $i . ']', 'value' => $model->{$option}]) . "</div><div class='help-block'>" . $error . "</div></div>"; break; case 7: // Изображение (загрузка) echo "<div class='{$class}'>" . Html::activeLabel($model, $option, ['class' => 'control-label']) . FileInput::widget(['model' => $model, 'attribute' => $option_file, 'pluginOptions' => ['browseClass' => 'btn btn-default', 'browseLabel' => 'Загрузить файл', 'removeLabel' => 'Удалить', 'removeClass' => 'btn btn-default', 'browseIcon' => '', 'removeIcon' => '', 'showUpload' => false]]) . Html::activeHiddenInput($model, $option_file, $options_attributes); if (!$model->isNewRecord && $model->{$option} && $model->last_template_id == $model->template_id) { echo Html::img($model->{$option}, ['class' => 'doc_img img-thumbnail']) . "<p>" . Html::a('Удалить изображение', ['/document/deleteimg', 'document_id' => $model->id, 'option_id' => $i], ['class' => 'lnk delete_photo']) . "</p>"; } echo "<div class='help-block'>" . $error . "</div></div>"; break; case 8: // Список дочерних документов echo "<div class='{$class}'>" . Html::activeLabel($model, $option, ['class' => 'control-label']) . Select2::widget(['model' => $model, 'attribute' => $option, 'data' => Document::getChilds($template->{$option_param}, true), 'options' => ['placeholder' => ''], 'pluginOptions' => $options_attributes]) . "<div class='help-block'>" . $error . "</div></div>"; break; case 9: // Список потомков документов echo "<div class='{$class}'>" . Html::activeLabel($model, $option, ['class' => 'control-label']) . Select2::widget(['model' => $model, 'attribute' => $option, 'data' => Document::getChilds($template->{$option_param}, false), 'options' => ['placeholder' => ''], 'pluginOptions' => $options_attributes]) . "<div class='help-block'>" . $error . "</div></div>"; break; case 10: // Список пользователя echo "<div class='{$class}'>" . Html::activeLabel($model, $option, ['class' => 'control-label']) . Select2::widget(['model' => $model, 'attribute' => $option, 'data' => User::getAll(), 'options' => ['placeholder' => ''], 'pluginOptions' => $options_attributes]) . "<div class='help-block'>" . $error . "</div></div>"; break; }
private static function _entityDecoder($attributes, $matches) { if (isset($attributes['type'])) { switch ($attributes['type']) { case 'document': $entityType = Entity::mapType($attributes['type']); $itemNo = $attributes['data-itemno']; $entityType = Entity::mapType($attributes['type']); $entity = Document::findOne(['type' => 5, 'refId' => $attributes['data-id'], 'itemNo' => $itemNo]); break; default: $entityType = Entity::mapType($attributes['type']); $entity = Entity::getInstance($entityType, $attributes['data-id']); break; } } if (empty($entity)) { return; } switch ($entityType) { case Entity::TYPE_DOCUMENT: $result = self::_documentReplace($entity, $attributes); break; case Entity::TYPE_GALLERY: $result = self::_galleryReplace($entity, $attributes); break; case Entity::TYPE_FEED: $result = self::_feedReplace($entity, $attributes); break; case Entity::TYPE_QUOTE: $result = self::_quoteReplace($entity, $attributes); break; default: $result = $entity->getPreview(array(Media::ENCODE_WIDTH => 532)); break; } return $result; }
/** * Finds the Document model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Document the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { /** @var \common\models\Document $model */ $model = Document::findOne($id); if ($model !== null) { $model->last_parent_id = $model->parent_id; $model->last_template_id = $model->template_id; $model->initialization(); return $model; } else { throw new NotFoundHttpException('Страница не найдена.'); } }
public function actionRelease($id) { //$model = $this->findModel($id); $model = new Pendingdoc(); $userid = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'user_id'); $userFName = ArrayHelper::getValue(User::find()->where(['id' => $userid])->one(), 'userFName'); $userLName = ArrayHelper::getValue(User::find()->where(['id' => $userid])->one(), 'userLName'); $section = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'section_id'); $documentname = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'documentName'); if ($model->load(Yii::$app->request->post())) { $model->pendingDocFName = $userFName . $userLName; $model->pendingDocSection = $section; $model->pendingDocName = $documentname; if ($model->save()) { return $this->redirect(['document/index']); } } else { return $this->renderAjax('release', ['model' => $model]); } }
} }], ['attribute' => 'attachment', 'format' => 'raw', 'value' => function ($model) { if ($model->attachment) { return CFF::shortString($model->attachment, 200); } else { return null; } }], ['attribute' => 'for_document_id', 'format' => 'raw', 'value' => function ($model) { if ($model->for_document_id) { $return = isset($model->for_document_id) ? Html::a($model->forDocument->name, ['/document/update', 'id' => $model->for_document_id]) : ""; $return .= " (" . $model->for_document_id . ")"; return $return; } else { return null; } }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => Document::getAll(), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => ' ', 'class' => 'form-control']], ['attribute' => 'for_user_id', 'value' => function ($model) { $return = ''; if ($model->for_user_id) { if (isset($model->forUser)) { $user = $model->forUser; $return = $user->first_name; if ($user->last_name) { $return .= " " . $user->last_name; } } $return .= " (" . $model->for_user_id . ")"; return $return; } else { return null; } }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => User::getAll(), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => ' ', 'class' => 'form-control'], 'format' => 'raw'], ['attribute' => 'parent_message_id', 'width' => '70px'], ['attribute' => 'created_at', 'value' => function ($model) {
/** * @return bool * @throws \yii\db\Exception * Сохранение файлов для возможных файлов "быстрых" полей */ public function savePhoto() { for ($i = 1; $i <= Template::OPTIONS_COUNT; $i++) { $option_file = 'option_' . $i . '_file'; $option = 'option_' . $i; if ($this->{$option_file}) { $this->deletePhoto($i); $ext = "." . end(explode(".", $this->{$option_file})); if ($ext === ".") { $ext = '.jpg'; } $name = $this->alias . "_" . $i; $path = self::FROM_ADM_PATH . self::FILES_PATH . $this->id . '/'; $fullname = $path . $name . $ext; if (!file_exists($path)) { mkdir($path, 0777, true); } $this->{$option_file}->saveAs($fullname); $this->{$option_file} = $fullname; Image::thumbnail($fullname, 300, 200, $mode = ManipulatorInterface::THUMBNAIL_OUTBOUND)->save($path . $name . '_thumb' . $ext, ['quality' => 100]); $this->{$option} = self::FILES_PATH . $this->id . '/' . $name . $ext; if (!$this->isNewRecord) { $db = Document::getDb(); $db->createCommand()->update('document', [$option => $this->{$option}], ['id' => $this->id])->execute(); } else { $this->save(); } } } return true; }
private function saveData() { $request = \Yii::$app->request; $arrParams = $request->bodyParams; $arrPimaryKey = []; //type if (!empty($arrParams[1])) { $arrPimaryKey['type'] = $arrParams[1]; } //refId if (!empty($arrParams[2])) { $arrPimaryKey['refId'] = $arrParams[2]; } //itemNo if (!empty($arrParams[3])) { $arrPimaryKey['itemNo'] = $arrParams[3]; } $document = Document::findOne($arrPimaryKey); if ($document == null) { throw new HttpException(404); } $document->caption = $request->post('caption'); $document->tags = $request->post('tags'); if ($document->save()) { return 'บันทึกข้อมูลเอกสารแล้ว'; } else { throw new HttpException(500, join("\n", $document->getErrors())); } }
echo "<img src='" . $model->img . "' class='doc_img'>"; } ?> </div> </div> <div class="row"> <div class="col-sm-6"> <?php echo $form->field($model, 'img')->widget(InputFile::className(), ['language' => 'ru', 'controller' => 'elfinder', 'filter' => 'image', 'template' => '<div class="input-group"> {input}<span class="input-group-btn">{button}</span> </div>', 'options' => ['class' => 'form-control'], 'buttonName' => 'Выбрать файл', 'buttonOptions' => ['class' => 'btn btn-default'], 'multiple' => false]); ?> </div> <div class="col-sm-6"> <?php echo $form->field($model, 'status')->dropDownList(Document::getStatuses()); ?> </div> </div> </div> </div> <div id="options"> <?php echo $this->render('_options_fields', ['model' => $model, 'template' => $template]); ?> </div> <?php ActiveForm::end(); ?>
break; case Document::STATUS_ACTIVE: return '<span class="label label-success"> <i class="glyphicon glyphicon-ok"></i> ' . Document::getStatuses()[$model->status] . '</span>'; break; case Document::STATUS_WITHOUT_NAV: return '<span class="label label-primary"> <i class="glyphicon glyphicon-ok"></i> ' . Document::getStatuses()[$model->status] . '</span>'; break; case Document::STATUS_ONLY_NAV: return '<span class="label label-warning"> <i class="glyphicon glyphicon-ok"></i> ' . Document::getStatuses()[$model->status] . '</span>'; break; } return false; }, 'filter' => Document::getStatuses()], ['class' => 'kartik\\grid\\ActionColumn'], ['class' => 'kartik\\grid\\CheckboxColumn', 'headerOptions' => ['class' => 'kartik-sheet-style']]]; echo GridView::widget(['layout' => "{items}\n{summary}\n{pager}", 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns, 'toggleDataContainer' => ['class' => 'btn-group-sm'], 'exportContainer' => ['class' => 'btn-group-sm'], 'containerOptions' => ['style' => 'overflow: auto'], 'headerRowOptions' => ['class' => 'kartik-sheet-style'], 'filterRowOptions' => ['class' => 'kartik-sheet-style'], 'pjax' => false, 'panel' => ['heading' => '<h3 class="panel-title"> <span class="glyphicon glyphicon-file"></span> Поиск по документам </h3>', 'type' => GridView::TYPE_PRIMARY, 'before' => Html::a('<span class="glyphicon glyphicon-plus"></span> Создать', ['create'], ['class' => 'btn btn-success']), 'after' => "<div class='text-right'><b>Выбранные:</b> " . Html::button('<span class="glyphicon glyphicon-eye-open"></span> Опубликовать', ['class' => 'btn btn-default open-all']) . " " . Html::button('<span class="glyphicon glyphicon-eye-close"></span> Скрыть', ['class' => 'btn btn-default close-all']) . " " . Html::button('<span class="glyphicon glyphicon-trash"></span> Удалить', ['class' => 'btn btn-danger delete-all']) . "</div>"], 'export' => ['fontAwesome' => true], 'bordered' => true, 'striped' => true, 'condensed' => true, 'persistResize' => false, 'hover' => true, 'responsive' => true]); ?> </div> <?php $this->registerJs(' $(".delete-all").click(function(){ var keys = $(".grid-view").yiiGridView("getSelectedRows"); $.ajax({ url: "/admin/document/multidelete", type:"POST", data:{keys: keys},
/** * @return \yii\db\ActiveQuery */ public function getDocuments() { return $this->hasMany(Document::className(), ['type_id' => 'id']); }
/** * Finds the Document model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Document the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Document::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getDocument() { return $this->hasOne(Document::className(), ['id' => 'document_id']); }
<?php use common\models\Document; $data = []; $documents = Document::find()->orderBy('lft')->all(); if ($documents) { foreach ($documents as $doc) { $d = []; $d['id'] = $doc->id; $d['parent'] = $doc->parent_id ? $doc->parent_id : '#'; $d['text'] = $doc->name . ' <span class="node-id">(' . $doc->id . ')</span>'; if ($doc->is_folder) { if ($doc->status) { $d['icon'] = '/admin/css/image/icon-folder.png'; } else { $d['icon'] = '/admin/css/image/icon-folder-disable.png'; } } else { if ($doc->status) { $d['icon'] = '/admin/css/image/icon-file.png'; } else { $d['icon'] = '/admin/css/image/icon-file-disable.png'; } } $d['status'] = $doc->status; if (!$doc->depth) { $d['state'] = ['opened' => true]; } $data[] = $d; } }