Ejemplo n.º 1
0
 public function actionSettings()
 {
     $model = Fregatsettings::findOne(1);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(Proc::GetPreviousURLBreadcrumbsFromSession());
     } else {
         return $this->render('//Fregat/config/settingsupdate', ['model' => $model]);
     }
 }
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(Proc::GetPreviousURLBreadcrumbsFromSession());
     } else {
         $searchModel = new RecoveryrecieveaktSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         $searchModelmat = new RecoveryrecieveaktmatSearch();
         $dataProvidermat = $searchModelmat->search(Yii::$app->request->queryParams);
         $generalsettings = Fregatsettings::findOne(1);
         return $this->render('update', ['model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'searchModelmat' => $searchModelmat, 'dataProvidermat' => $dataProvidermat, 'emailfrom' => $generalsettings->fregatsettings_recoverysend_emailfrom, 'emailtheme' => $generalsettings->fregatsettings_recoverysend_emailtheme]);
     }
 }
Ejemplo n.º 3
0
 public function actionOsmotraktSend()
 {
     $dopparams = json_decode(Yii::$app->request->post()['dopparams']);
     if (Yii::$app->request->isAjax) {
         $organ_id = Yii::$app->request->post('organ_id');
         if (!empty($dopparams->id) && !empty($organ_id)) {
             $Organ = Organ::findOne($organ_id);
             if (!empty($Organ->organ_email)) {
                 $Report = new OsmotraktReport();
                 $Report->setDirectoryFiles('tmpfiles');
                 $filename = $Report->Execute();
                 $fnutf8 = $filename;
                 $fregatsettings = Fregatsettings::findOne(1);
                 $fl = DIRECTORY_SEPARATOR === '/' ? 'tmpfiles/' . $filename : mb_convert_encoding('tmpfiles/' . $filename, 'Windows-1251', 'UTF-8');
                 $sended = Yii::$app->mailer->compose('//Fregat/osmotrakt/_send', ['filename' => $filename])->setFrom($fregatsettings->fregatsettings_recoverysend_emailfrom)->setTo([YII_DEBUG ? '*****@*****.**' : Organ::findOne($organ_id)->organ_email])->setSubject($fregatsettings->fregatsettings_recoverysend_emailtheme)->attach($fl, ['fileName' => $fnutf8])->send();
                 if (!$sended) {
                     throw new HttpException(500, 'Возникла ошибка при отправке письма');
                 } else {
                     $FileName = DIRECTORY_SEPARATOR === '/' ? 'tmpfiles/' . $filename : mb_convert_encoding('tmpfiles/' . $filename, 'Windows-1251', 'UTF-8');
                     unlink($FileName);
                 }
                 echo $fnutf8;
             } else {
                 throw new HttpException(500, 'Не заполнен Email у организации');
             }
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @param $Typereport
  */
 public static function SendReportAkt($Typereport)
 {
     $dopparams = json_decode(Yii::$app->request->post()['dopparams']);
     if (!empty($dopparams)) {
         $email = Recoverysendakt::findOne($dopparams->id)->idOrgan->organ_email;
         if (!empty($email)) {
             $Report = $Typereport === 1 ? new RecoverysendaktReport() : new RecoverysendaktmatReport();
             $Report->setDirectoryFiles('tmpfiles');
             $filename = $Report->Execute();
             $fnutf8 = $filename;
             $fregatsettings = Fregatsettings::findOne(1);
             $fl = DIRECTORY_SEPARATOR === '/' ? 'tmpfiles/' . $filename : mb_convert_encoding('tmpfiles/' . $filename, 'Windows-1251', 'UTF-8');
             Yii::$app->mailer->compose('//Fregat/recoverysendakt/_send', ['filename' => $filename])->setFrom($fregatsettings->fregatsettings_recoverysend_emailfrom)->setTo([YII_DEBUG ? '*****@*****.**' : Recoverysendakt::findOne($dopparams->id)->idOrgan->organ_email])->setSubject($fregatsettings->fregatsettings_recoverysend_emailtheme)->attach($fl, ['fileName' => $fnutf8])->send();
             echo $fnutf8;
         } else {
             throw new \Exception('У организации ' . Recoverysendakt::findOne($dopparams->id)->idOrgan->organ_name . ' отсутствует E-mail');
         }
     } else {
         throw new \Exception('Не передан параметр POST dopparams');
     }
 }