public function actionApproveAll() { if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; $request = Yii::$app->request; $dataKeySelect = $request->post('keysSelect'); foreach ($dataKeySelect as $key => $value) { $model = DraftPlanDetail::find()->where(['LIKE', 'ID', $value])->one(); $scdl_group_nm = $model->SCDL_GROUP_NM; $cus_id = $model->CUST_ID; $cari_user = DraftPlanGroup::find()->where(['SCL_NM' => $scdl_group_nm])->one(); if ($cari_user->USER_ID != '') { $transaction = DraftPlanDetail::getDb()->beginTransaction(); try { self::conn_esm()->createCommand()->update('c0002scdl_plan_detail', ['STATUS' => 1], 'ID LIKE"' . $value . '" AND STATUS = 0')->execute(); self::conn_esm()->createCommand()->update('c0002scdl_plan_header', ['STATUS' => 1, 'USER_ID' => $cari_user->USER_ID], 'NOTE="' . $scdl_group_nm . '" AND STATUS = 0')->execute(); self::conn_esm()->createCommand()->update('c0002scdl_plan', ['STATUS' => 1], 'CUST_KD="' . $cus_id . '" AND STATUS = 0')->execute(); // ...other DB operations... $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); throw $e; } // self::conn_esm()->createCommand()->update('c0002scdl_plan_detail',['STATUS'=>1,'CUST_ID'=>$cus_id],'ID LIKE"'.$value.'" AND STATUS = 0')->execute(); // self::conn_esm()->createCommand()->update('c0002scdl_plan_header',['STATUS'=>1,'USER_ID'=>$cari_user->USER_ID],'NOTE="'.$scdl_group_nm.'" AND STATUS = 0')->execute(); // self::conn_esm()->createCommand()->update('c0002scdl_plan',['STATUS'=>1],'CUST_KD="'.$model->CUST_ID.'" AND STATUS = 0')->execute(); } } return true; } return $this->redirect(['index?tab=1']); }