function actionSave()
 {
     $idcompany = 2;
     $name = $_POST['name'];
     $date = strtoupper(date("d-M-y h.i.s.u A"));
     $model = new Project();
     $no = $model->find()->select(['FIELD1'])->orderby(['FIELD1' => SORT_DESC])->asArray()->scalar();
     $model->FIELD1 = $no + 1;
     $model->FIELD2 = $idcompany;
     $model->FIELD3 = $name;
     $model->FIELD4 = '';
     if ($model->insert()) {
         echo "sukses";
     } else {
         echo $date;
     }
     echo "wreewrewr";
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Project::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(['date_of_flob' => $this->date_of_flob, 'date_of_completion' => $this->date_of_completion, 'percentage_of_completion' => $this->percentage_of_completion]);
     $query->joinWith('sitename');
     $query->joinWith('pic');
     $query->joinWith('account');
     $query->andFilterWhere(['like', 'projectcode', $this->projectcode])->andFilterWhere(['like', 'projectname', $this->projectname])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'contractor', $this->contractor])->andFilterWhere(['like', 'sitename.sitename', $this->sitename_id])->andFilterWhere(['like', 'account.acct_name', $this->account_id])->andFilterWhere(['like', 'pic.pic_fullName', $this->pic_id])->andFilterWhere(['like', 'remarks', $this->remarks]);
     return $dataProvider;
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProjects()
 {
     return $this->hasMany(Project::className(), ['user_id' => 'id']);
 }
 /**
  * Finds the Project model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Project the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Project::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }