public function actionSettingProfile($id)
 {
     $model = Userprofile::find()->where(['ID' => $id])->one();
     $distributor = ArrayHelper::map(Distributor::find()->where('STATUS <>3')->all(), 'KD_DISTRIBUTOR', 'NM_DISTRIBUTOR');
     $username = Yii::$app->getUserOptcrm->Profile_user()->username;
     //component Crm
     if ($model->load(Yii::$app->request->post())) {
         $model->CREATED_BY = $username;
         $model->UPDATED_TIME = date('Y-m-d h:i:s');
         $base64File = \yii\web\UploadedFile::getInstance($model, 'image');
         $File64 = $this->saveimage(file_get_contents($base64File->tempName));
         $model->IMG_BASE64 = 'data:' . $base64File->type . ';charset=utf-8;base64,' . $File64;
         $model->save();
         return $this->redirect('index');
     } else {
         return $this->renderAjax('set_profile', ['model' => $model, 'distributor' => $distributor]);
     }
 }
Example #2
0
 public function getDis()
 {
     return $this->hasOne(Distributor::className(), ['KD_DISTRIBUTOR' => 'KD_DISTRIBUTOR']);
 }