public function actionUpdate($id) { $users_pi = Users::find()->select(['id', 'username'])->where(['status' => '3'])->orderBy('username')->all(); $pi = ArrayHelper::map($users_pi, 'id', 'username'); $users_regional = Users::find()->select(['id', 'username'])->where(['status' => '2'])->orderBy('username')->all(); $regional = ArrayHelper::map($users_regional, 'id', 'username'); $urf = Ur::find()->select(['id', 'name'])->orderBy('name')->all(); $ur = ArrayHelper::map($urf, 'id', 'name'); $model = $this->findModel($id); $urOne = Ur::findOne($model['ur_l_id']); if ($model->load(Yii::$app->request->post()) && $model->save()) { // return $this->render(['update', 'id' => $model->id,'ok'=>'1','pi'=>$pi,'regional'=>$regional ,'ur'=>$ur]); return $this->render('update', ['model' => $model, 'pi' => $pi, 'regional' => $regional, 'ur' => $ur, 'urOne' => $urOne, 'ok' => '1']); } else { return $this->render('update', ['model' => $model, 'pi' => $pi, 'regional' => $regional, 'urOne' => $urOne, 'ur' => $ur]); } }
public function actionExample() { $UrRecords = Ur::findOne(1); $RegionRecords = [Region::findOne(2), Region::findOne(3)]; $extraColumns = []; // extra columns to be saved to the many to many table $unlink = true; // unlink tags not in the list $delete = true; // delete unlinked tags $UrRecords->linkAll('RegionRecords', $RegionRecords, $extraColumns, $unlink, $delete); $UrRecords->save(); // var_dump($UrRecords); // exit; }
use app\models\Users; /* @var $this yii\web\View */ /* @var $model app\models\UrQuestions */ $this->title = $model->id; $this->params['breadcrumbs'][] = ['label' => 'Юридические вопросы', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="ur-questions-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <!-- <p> <?php echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('Delete', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]); ?> </p> --> <?php echo DetailView::widget(['model' => $model, 'attributes' => [['label' => 'Юридическое лицо', 'value' => ArrayHelper::getValue(Ur::findOne($model->ur_l_id), 'name')], ['label' => 'Отправлен', 'value' => ArrayHelper::getValue(Users::findOne($model->user_id), 'username')], 'question:ntext', 'ansver:ntext', ['label' => 'Файлы', 'format' => 'raw', 'value' => $model->viewFiles($model->qfiles)], 'created_at', 'date_ansver']]); ?> </div>
/** * пароль для юр лица */ public function actionUpdate2($id) { // $this->layout = 'modal'; $model = SbSiteUsers::findOne(['ur_l_id' => $id]); if ($model == null) { $model = new SbSiteUsers(); $save = 1; } if (Yii::$app->request->isAjax) { $model->load($_POST); Yii::$app->response->format = 'json'; return ActiveForm::validate($model); } elseif ($model->load($_POST)) { $model->ur_l_id = $id; $model->su_domains = "sojuzpharma.ru"; $model->su_pass = md5($model->password_simple); //Получаеи информацию об аптеки $apt = Ur::findOne(['id' => $id]); $model->su_name = $apt['name']; $model->su_email = $apt['contact_mail']; if ($_POST['sendMail']) { \Yii::$app->mail->compose('ur_l_pass', ['login' => $model->su_id, 'pass' => $model->password_simple, 'name' => $apt['name'], 'contact_face' => $apt['contact_face']])->setFrom([\Yii::$app->params['infoEmail'] => 'СоюзФарма'])->setTo($apt['contact_mail'])->setSubject('Для вашего юр.лица заведена учетная запись')->send(); } if ($model->save()) { if ($save) { $model3 = SbSiteUsers::findOne(['ur_l_id' => $id]); $model3->su_login = $model->su_id; $model3->save(); $model2 = new SbCatlinks(); $model2->link_cat_id = '21'; $model2->link_el_id = $model->su_id; $model2->save(); } return $this->redirect(['/ur/update', 'id' => $model->ur_l_id]); } } else { return $this->render('update', ['model' => $model, 'id' => $id]); } }