/**
  * Creates a new EntriSheet model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new EntriSheet();
     $post = Yii::$app->request->post();
     if ($model->load($post)) {
         try {
             $transaction = Yii::$app->db->beginTransaction();
             $success = $model->save();
             $success = $model->saveRelated('entriSheetDtls', $post, $success);
             if ($success) {
                 $error = false;
                 if (count($model->entriSheetDtls) == 0) {
                     $model->addError('', 'Detail cannot be blank');
                     $error = true;
                 }
                 //
                 if ($error) {
                     $transaction->rollBack();
                 } else {
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $model->id_esheet]);
                 }
             } else {
                 $transaction->rollBack();
             }
         } catch (\Exception $exc) {
             $transaction->rollBack();
             $model->addError('', $exc->getMessage());
         }
         $model->setIsNewRecord(true);
     }
     return $this->render('create', ['model' => $model]);
 }