예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
 /**
  * @return array
  * Вывод всех документов с ID массивом
  */
 public static function getAll()
 {
     $documents = [];
     $models = Document::find()->all();
     if ($models) {
         foreach ($models as $model) {
             $documents[$model->id] = $model->name . " (" . $model->id . ")";
         }
     }
     return $documents;
 }
예제 #5
0
 /**
  * ดึงข้อมูลจาก 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;
 }
예제 #6
0
	
	<?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"));
                    }
                }
예제 #7
0
<?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;
    }
}
 public function actionRelease($id)
 {
     $model = $this->findModel($id);
     $workflowid = ArrayHelper::getValue(Docworkflow::find()->where(['document_id' => $id])->orderBy(['id' => SORT_DESC])->one(), 'id');
     //print_r($workflowid . ' level0 ' . $model->user_id);
     if ($model->load(Yii::$app->request->post())) {
         //$userid1 = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'id');
         $sectionid = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'section_id');
         $userFName = ArrayHelper::getValue(User::find()->where(['id' => $model->user_id])->one(), 'userFName');
         $userLName = ArrayHelper::getValue(User::find()->where(['id' => $model->user_id])->one(), 'userLName');
         $section = ArrayHelper::getValue(Section::find()->where(['id' => $sectionid])->one(), 'sectionName');
         $documentname = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'documentName');
         $pendingdoc = new Pendingdoc();
         $pendingdoc->pendingDocFName = $userLName . ', ' . $userFName;
         $pendingdoc->pendingDocSection = $section;
         $pendingdoc->pendingDocName = $documentname;
         if ($workflowid == null) {
             if ($pendingdoc->save()) {
                 print_r('level3');
                 return $this->redirect(['index']);
                 //return $this->redirect('index.php?r=pendingdoc');
             }
         } else {
             $workflow1 = new Docworkflow();
             $workflow1 = $this->findModelWorkflow($workflowid);
             //$workflow1->id = $workflowid;
             $workflow1->timeRelease = date('Y-m-d H:i:s');
             //$workflow1->totalTimeSpent = date('Y-m-d H:i:s');
             $workflow1->user_release = $model->user_id;
             print_r('level1');
             if ($workflow1->save()) {
                 print_r('level2');
                 if ($pendingdoc->save()) {
                     print_r('level3');
                     return $this->redirect(['index']);
                     //return $this->redirect('index.php?r=pendingdoc');
                 }
             }
         }
     } else {
         return $this->renderAjax('release', ['model' => $model]);
     }
 }
 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]);
     }
 }
예제 #10
0
 protected function findDocuments($research_id)
 {
     if (count($model = Document::find()->byResearch($research_id)->all()) > 0) {
         return $model;
     } else {
         $this->createDocument($research_id);
         return $this->findDocuments($research_id);
     }
 }
 private function doQuery()
 {
     $request = \Yii::$app->request;
     $id = $request->post('id', $request->get('id', ''));
     //เพิ่มการแสดงรูปสำหรับ type อื่น เช่น กิจกรรม
     $type = Entity::TYPE_CONTENT;
     if ($request->post('entity')) {
         $request->post('entity');
     }
     $items = array();
     $query = Document::find();
     $query->andWhere('refId=:id AND type=:type', [':id' => $id, ':type' => $type]);
     $items = Document::getItems($query, $options);
     \Yii::$app->response->format = 'json';
     echo json_encode($items);
 }