Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Logs::find();
     $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(['milestone_date' => $this->milestone_date]);
     $query->joinWith('project');
     $query->andFilterWhere(['like', 'logs_employee_name', $this->logs_employee_name])->andFilterWhere(['like', 'project.projectcode', $this->project_id])->andFilterWhere(['like', 'milestone', $this->milestone]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Finds the Logs model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Logs the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Logs::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Lists all Project models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new ProjectSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     // validate if there is a editable input saved via AJAX
     if (Yii::$app->request->post('hasEditable')) {
         // instantiate your book model for saving
         $projectId = Yii::$app->request->post('editableKey');
         $model = Project::findOne($projectId);
         // store a default json response as desired by editable
         //$out = Json::encode(['output'=>'', 'message'=>'']);
         $firstname = Yii::$app->user->identity->firstname;
         $lastname = Yii::$app->user->identity->lastname;
         $status = $model->projectname;
         $post = [];
         $posted = current($_POST['Project']);
         $post['Project'] = $posted;
         $a = $posted;
         // load model like any single model validation
         if ($model->load($post)) {
             // can save model or do something before saving model
             // $logC->save();
             //$model->save();
             $output = '';
             $logC = new Logs();
             $logC->logs_employee_name = $firstname . " " . $lastname;
             date_default_timezone_set('Asia/Manila');
             $logC->milestone_date = date('Y-m-d') . " " . date("h:i:sa");
             $logC->project_id = $projectId;
             $b = json_encode($a);
             // $c = json_decode($b);
             echo $b;
             $c = json_decode($b);
             foreach ($c as $key => $value) {
             }
             //echo $value;
             //------------------------------------- For Status----------------------------------------
             if ($key == "percentage_of_completion") {
                 if ($model->percentage_of_completion == 90) {
                     $model->status = "PHYSICALLY COMPLETED";
                 } else {
                     if ($model->percentage_of_completion == 91) {
                         $model->status = "PHYSICALLY COMPLETED";
                     } else {
                         if ($model->percentage_of_completion == 92) {
                             $model->status = "PHYSICALLY COMPLETED";
                         } else {
                             if ($model->percentage_of_completion == 93) {
                                 $model->status = "PHYSICALLY COMPLETED";
                             } else {
                                 if ($model->percentage_of_completion == 94) {
                                     $model->status = "PHYSICALLY COMPLETED";
                                 } else {
                                     if ($model->percentage_of_completion == 95) {
                                         $model->status = "PHYSICALLY COMPLETED";
                                     } else {
                                         if ($model->percentage_of_completion == 96) {
                                             $model->status = "PHYSICALLY COMPLETED";
                                         } else {
                                             if ($model->percentage_of_completion == 97) {
                                                 $model->status = "PHYSICALLY COMPLETED";
                                             } else {
                                                 if ($model->percentage_of_completion == 98) {
                                                     $model->status = "PHYSICALLY COMPLETED";
                                                 } else {
                                                     if ($model->percentage_of_completion == 99) {
                                                         $model->status = "PHYSICALLY COMPLETED";
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($model->percentage_of_completion == 100) {
                     $model->status = "ACCEPTED";
                 }
             }
             //----------------------------------------------------------------------------------------
             if ($key == "status") {
                 if ($model->status == "CANCELED") {
                     $model->percentage_of_completion = 0;
                 }
                 if ($model->status == "PHYSICALLY COMPLETED") {
                     $model->percentage_of_completion = 90;
                 }
                 if ($model->status == "ACCEPTED") {
                     $model->percentage_of_completion = 100;
                 }
             }
             //-------------------------------------For Site Code --------------------------------------
             if ($key == "sitename_id") {
                 $sitecode = $model->sitename_id;
                 $projectCode = $model->projectcode;
                 $connection = \Yii::$app->db;
                 $sql5 = $connection->createCommand('SELECT  sitecode  FROM sitename WHERE id =' . $value)->queryAll();
                 $encode5 = json_encode($sql5);
                 $decode5 = json_decode($encode5);
                 foreach ($decode5 as $key5 => $value5) {
                     $sitecode = $decode5[$key5]->sitecode;
                 }
                 //echo $sitecode;
                 $projectExplode = explode("-", $projectCode);
                 foreach ($projectExplode as $key6 => $value6) {
                     $date = $projectExplode[1];
                     $idCode = $projectExplode[2];
                 }
                 $mergeProjectCode = $sitecode . "-" . $date . "-" . $idCode;
                 $model->projectcode = $mergeProjectCode;
             }
             //----------------------------------------------------------------------------------------
             if ($key == "pic_id") {
                 $connection = \Yii::$app->db;
                 $sql = $connection->createCommand('SELECT  pic_fullName  FROM pic WHERE id =' . $value)->queryAll();
                 $encode = json_encode($sql);
                 $decode = json_decode($encode);
                 foreach ($decode as $key2 => $value2) {
                     $picName = $decode[$key2]->pic_fullName;
                 }
                 $logC->milestone = "Person in charge " . ' | ' . $picName . ' UPDATED';
             } else {
                 if ($key == "sitename_id") {
                     $connection = \Yii::$app->db;
                     $sql3 = $connection->createCommand('SELECT  sitename  FROM sitename WHERE id =' . $value)->queryAll();
                     $encode3 = json_encode($sql3);
                     $decode3 = json_decode($encode3);
                     foreach ($decode3 as $key3 => $value3) {
                         $sitename = $decode3[$key3]->sitename;
                     }
                     $logC->milestone = "Sitename" . ' | ' . $sitename . ' UPDATED';
                 } else {
                     if ($key == "account_id") {
                         $connection = \Yii::$app->db;
                         $sql4 = $connection->createCommand('SELECT  acct_name  FROM account WHERE id =' . $value)->queryAll();
                         $encode4 = json_encode($sql4);
                         $decode4 = json_decode($encode4);
                         foreach ($decode4 as $key4 => $value4) {
                             $acctName = $decode4[$key4]->acct_name;
                         }
                         $logC->milestone = "Account" . ' | ' . $acctName . ' UPDATED';
                     } else {
                         if ($key == "contractor") {
                             $logC->milestone = "Contractor" . ' | ' . $value . ' UPDATED';
                         } else {
                             if ($key == "date_of_flob") {
                                 $logC->milestone = "Date of Mobilization" . ' | ' . $value . ' UPDATED';
                             } else {
                                 if ($key == "date_of_completion") {
                                     $logC->milestone = "Date of Completion" . ' | ' . $value . ' UPDATED';
                                 } else {
                                     if ($key == "percentage_of_completion") {
                                         $logC->milestone = "% of Completion" . ' | ' . $value . ' UPDATED';
                                     } else {
                                         if ($key == "remarks") {
                                             $logC->milestone = "Remarks" . ' | ' . $value . ' UPDATED';
                                         } else {
                                             $logC->milestone = $key . ' | ' . $value . ' UPDATED';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             $logC->save();
             $model->save();
             //return $this->redirect(['project/index']);
             return $this->refresh();
             //  $out = Json::encode(['output'=>$output, 'message'=>'']);
         }
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Example #4
0
 public function getLogs0()
 {
     //return $this->hasOne(Logs::className(), ['id' => 'logs_id']);
     return $this->hasOne(Logs::className(), ['project_id' => 'id'])->orderBy(['id' => SORT_DESC])->limit(1);
 }