Exemplo n.º 1
0
 /**
  * Creates a new SoStatus model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new SoStatus();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->ID]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 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]);
     }
 }
 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()]);
     }
 }