public function actionMailvznos() { $all_name = ""; $n = 0; $kvaratal = Vznos::getKvartal(); $year = date('Y'); $vznos = Vznos::find()->select('ur_id')->where(['year' => $year])->andWhere(['kvartal' => $kvaratal])->column(); //Убрать лиимит $ur_array = Ur::find()->where(['not in', 'id', $vznos])->andWhere(['plat' => 1])->orderBy('name')->all(); //->limit(1) print "<h4>" . count($ur_array) . "</h4>"; foreach ($ur_array as $ur) { // print $ur['id']; print $ur['name']; // print "<br>"; Vznos::greatePDF($ur); // $ur['contact_mail']="*****@*****.**"; $file = \Yii::$app->basePath . '/temp/vznos/' . $ur['id'] . '.pdf'; $Subject = 'Оплата взносов ' . $kvaratal . " квартал " . $year . ' г.'; if (strpos($ur['contact_mail'], "@") !== false) { \Yii::$app->mail->compose('vznos', ['name' => $ur['name']])->setFrom([\Yii::$app->params['infoEmail'] => 'ААУ "СоюзФарма-ТМ"'])->setTo($ur['contact_mail'])->setSubject($Subject)->attach($file)->send(); sleep(1); $all_name .= $ur['name'] . " " . $ur['contact_mail'] . "\n<br>"; $n++; } } // $pdf = Vznos::greatePDF('Пукась Анна Андреевич'); \Yii::$app->mail->compose('infovznos', ['info' => $all_name, 'n' => $n])->setFrom([\Yii::$app->params['infoEmail'] => 'СоюзФарма'])->setTo("*****@*****.**")->setSubject('Рассылка произведена')->send(); \Yii::$app->mail->compose('infovznos', ['info' => $all_name, 'n' => $n])->setFrom([\Yii::$app->params['infoEmail'] => 'СоюзФарма'])->setTo("*****@*****.**")->setSubject('Рассылка произведена')->send(); }
public function actionIndex($user = null, $date = null, $trimestr = null, $scroll = null) { if (\Yii::$app->user->identity->status == 3) { $user = \Yii::$app->user->identity->id; } //$model = Preparats::find()->where(['region_id' => $region])->orderBy('name')->all(); if ($user) { //$apteki = Apteki::find()->where(['pi_id' => $user, 'farmopeka' => '1'])->orderBy('address')->all(); $query = new Query(); $query->select(['ur_l.name', 'apteki.address', 'apteki.id']); $query->from('apteki'); $query->LeftJoin('ur_l', 'ur_l.id = apteki.ur_l_id'); $query->andFilterWhere(['=', 'apteki.farmopeka', '1']); $query->andFilterWhere(['=', 'apteki.pi_id', $user]); //$query->orderBy('ur_l.name,apteki.address'); $query->orderBy(['ur_l.name' => SORT_ASC, 'apteki.address' => SORT_ASC]); $apteki = $query->all(); } if (!$date) { $date = date('Y-m-01'); } // if (!trimestr) $trimestr = Visitors::getTrimestr($date); if ($user) { $table = Visitors::getTable($user, $apteki, $date, $trimestr, $scroll); } // print \Yii::$app->params['infoEmail']; //Количество привязвнных ир.лиц и розничных точек $count['ur'] = Ur::find()->where(['pi_id' => $user])->andWhere(['farmopeka' => 1])->count(); $count['apteki'] = Apteki::find()->where(['pi_id' => $user])->andWhere(['farmopeka' => 1])->count(); return $this->render('index', ['user' => $user, 'table' => $table, 'date' => $date, 'trimestr' => $trimestr, 'count' => $count, 'scroll' => $scroll]); }
/** * Creates a new UrQuestions model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new UrQuestions(); $model->user_id = \Yii::$app->user->identity->id; $UrRecords = Ur::find()->orderBy('name'); if (\Yii::$app->user->identity->status == 2) { $UrRecords = $UrRecords->Where(['regional_id' => \Yii::$app->user->identity->id]); } if (\Yii::$app->user->identity->status == 3) { // $UrRecords = $UrRecords->Where(['pi_id' => \Yii::$app->user->identity->id]); } $UrRecords = $UrRecords->all(); //->where(['pi_id' => $user]) if (Yii::$app->request->isPost) { // print_r($model->qfile); $model->qfile = UploadedFile::getInstances($model, 'qfile'); if (!empty($model->qfile)) { $model->qfiles = ""; foreach ($model->qfile as $file) { $fileName = 'files/qfile/' . Functions::str2url($file->baseName) . rand(555, 99999) . '.' . $file->extension; $model->qfiles .= $fileName . "|"; $file->saveAs($fileName); } $model->qfiles = substr($model->qfiles, 0, -1); } } if ($model->load(Yii::$app->request->post()) && ($id = $model->save())) { $info = UrQuestions::getInfo($model->id); Word::ur_questions($info); return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model, 'UrRecords' => $UrRecords]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Ur::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); return $dataProvider; }
public function actionEdit($id) { if (Yii::$app->request->post()) { Ot::Update($id); } $apteka = Ur::find()->where(['id' => $id])->one(); $regionId = Ur::getRegionId($id); $db = new Query(); $db->from('preparats'); $db->where(['is_active' => 1, 'region_id' => $regionId]); $preparats = $db->all(); return $this->render('edit', ['preparats' => $preparats, 'id_apteka' => $id, 'apteka' => $apteka]); }
public function actionRegion2($id = null) { //Удаляет лишние регионы $ru = RegionUrL::find()->all(); foreach ($ru as $ru2) { $ur = null; //print_r($ru2); $ur = Ur::find()->where(['id' => $ru2['id_ur']])->all(); if (!$ur) { // $model = RegionUrL::findOne($ru2['id']); // $model->delete(); print $ru2['id_ur']; print "<br>"; } } }
public function actionEdit($id) { $user = Users::getOne($id); $status = $user['status']; $eng = Yii::$app->params['status_user_eng'][$status]; if ($status == '3') { $users = Users::find()->select(['id', 'username'])->where(['status' => '2'])->all(); $items = ArrayHelper::map($users, 'id', 'username'); } if ($status == 2) { $count['ur'] = Ur::find()->where(['regional_id' => $id])->count(); $count['apteki'] = Apteki::find()->where(['regional_id' => $id])->count(); } if ($status == 3) { $count['ur'] = Ur::find()->where(['pi_id' => $id])->count(); $count['apteki'] = Apteki::find()->where(['pi_id' => $id])->count(); } if ($eng == "") { throw new NotFoundHttpException('The requested page does not exist.'); } if (Yii::$app->request->post('Users')) { $user->attributes = Yii::$app->request->post('Users'); $user->photo = UploadedFile::getInstance($user, 'photo'); if ($user->validate() && $user->save()) { if ($user->photo && $user->photo->tempName) { $imagefile = 'img/user/' . $user->id . '.jpg'; $imagefileTh = 'img/user/th/' . $user->id . '.jpg'; $user->photo->saveAs('img/user/' . $user->id . '.jpg'); $img = Image::getImagine()->open(Yii::getAlias($imagefile)); $size = $img->getSize(); $ratio = $size->getWidth() / $size->getHeight(); $width = 200; $height = round($width / $ratio); Image::thumbnail($imagefile, $width, $height)->save($imagefileTh, ['quality' => 90]); $width = 1600; $height = round($width / $ratio); if ($size->getWidth() > 1600) { Image::thumbnail($imagefile, $width, $height)->save($imagefile, ['quality' => 97]); } } return $this->render($eng, ['model' => $user, 'items' => $items, 'id' => $id, 'status' => Yii::$app->params['status_user'][$status], 'ok' => 1, 'count' => $count]); } } return $this->render($eng, ['model' => $user, 'items' => $items, 'id' => $id, 'status' => Yii::$app->params['status_user'][$status], 'count' => $count]); }
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]); } }
/** * Updates an existing ValidationReport model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $model2 = ValidationReportViolation::find()->select('violation_id')->where(['report_id' => $id])->column(); $model->user_id = \Yii::$app->user->identity->id; $UrRecords = Ur::find()->orderBy('name'); if (\Yii::$app->user->identity->status == 2) { $UrRecords = $UrRecords->Where(['regional_id' => \Yii::$app->user->identity->id]); } if (\Yii::$app->user->identity->status == 3) { $UrRecords = $UrRecords->Where(['pi_id' => \Yii::$app->user->identity->id]); } $UrRecords = $UrRecords->all(); if ($model->load(Yii::$app->request->post())) { // ValidationReportViolation::deleteAll("report_id = $model->report_id"); } $ur_l = Apteki::findOne($model->apteka_id); $ur_l_id = $ur_l['ur_l_id']; $apteki = Apteki::find()->where(['ur_l_id' => $ur_l_id])->orderBy(['address' => 'desc'])->all(); if ($model->load(Yii::$app->request->post()) && $model->save()) { ValidationReportViolation::deleteAll(['report_id' => $model->id]); $post = Yii::$app->request->post(); if ($post['v']) { foreach ($post['v'] as $key => $item) { Yii::$app->db->createCommand()->insert('validation_report_violation', ['report_id' => $model->id, 'violation_id' => (int) $key])->execute(); } } return $this->redirect(['index', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'UrRecords' => $UrRecords, 'model2' => $model2, 'ur_l_id' => $ur_l_id, 'apteki' => $apteki]); } }
public function actionModalneoplatili2($ur_ls) { $url = explode(",", $ur_ls); $ur = Ur::find()->where(['id' => $url])->andWhere(['plat' => 1])->orderBy('name')->all(); $this->layout = 'modal_400'; return $this->render('modalneoplatili', compact(['ur'])); // return $this->render('index'); }