Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SoStatus::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['ID' => $this->ID, 'STT_PROCESS' => $this->STT_PROCESS, 'UPDATE_AT' => $this->UPDATE_AT]);
     $query->andFilterWhere(['like', 'KD_SO', $this->KD_SO])->andFilterWhere(['like', 'ID_USER', $this->ID_USER]);
     return $dataProvider;
 }
 public function actionCreateSales()
 {
     $model = new SoHeader();
     $model_status = new SoStatus();
     # code...
     if ($model->load(Yii::$app->request->post())) {
         # SoHeader
         $kode = Yii::$app->ambilkonci->getSMO();
         $model->KD_SO = $kode;
         $model->STT_PROCESS = 0;
         $model->CREATE_BY = Yii::$app->user->identity->id;
         # SoStatus
         $model_status->KD_SO = $kode;
         $model_status->ID_USER = $model->USER_SIGN1;
         $model_status->STT_PROCESS = 0;
         $transaction = self::Esm_connent()->beginTransaction();
         try {
             # SoHeader
             $model->save();
             # SoStatus
             $model_status->save();
             // ...other DB operations...
             $transaction->commit();
         } catch (\Exception $e) {
             $transaction->rollBack();
             throw $e;
         }
         return $this->redirect(['/purchasing/salesman-order/review-new', 'id' => $model->KD_SO, 'stt' => 1, 'cust_kd' => $model->CUST_ID, 'user_id' => $model->USER_SIGN1, 'tgl' => $model->TGL]);
     } else {
         return $this->renderAjax('new_so', ['model' => $model, 'data_cus' => self::get_aryCustomers(), 'data_user' => self::get_aryUser_id()]);
     }
 }
 public function actionSignAuth3($kdso)
 {
     $model = new Auth3Model();
     $model_header = $this->findModelHeader($kdso);
     $model_status = new SoStatus();
     $profile = Yii::$app->getUserOpt->Profile_user();
     $id = $profile->id;
     # code...
     if ($model->load(Yii::$app->request->post())) {
         $transaction = self::Esm_connent()->beginTransaction();
         try {
             # SoHeader
             $model_header->STT_PROCESS = $model->status;
             $model_header->USER_SIGN3 = $id;
             $model_header->TGL_SIGN2 = date('Y-m-d h:i:s');
             $model_header->save();
             # SoStatus
             $model_status->KD_SO = $model->kdso;
             $model_status->STT_PROCESS = $model->status;
             $model_status->ID_USER = $id;
             $model_status->save();
             // ...other DB operations...
             $transaction->commit();
         } catch (\Exception $e) {
             $transaction->rollBack();
             throw $e;
         }
         return $this->redirect(['/purchasing/salesman-order/review', 'id' => $kdso, 'stt' => 1]);
     } else {
         return $this->renderAjax('sign_3', ['model' => $model, 'kode_som' => $kdso]);
     }
 }
Ejemplo n.º 4
0
 /**
  * Finds the SoStatus model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return SoStatus the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = SoStatus::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }