replace yii object with baseobject

This commit is contained in:
Schneider Roland
2022-06-12 09:01:37 +02:00
parent 067fc72ce4
commit a7bbf4f96d
28 changed files with 96 additions and 96 deletions

View File

@@ -2,34 +2,34 @@
namespace common\components\accountstate;
use yii\base\Object;
use common\models\User;
use common\models\Account;
use common\models\AccountState;
use common\components\DailyListing;
use yii\base\BaseObject;
/**
* @property common\models\AccountState $model
* */
class AccountStateMail extends Object {
class AccountStateMail extends BaseObject {
public $controller;
public $model;
public $user;
public $account;
public $message;
public $details;
public function init(){
$this->user = User::findOne($this->model->id_user);
$this->account = Account::findOne($this->model->id_account);
$this->details = null;
if ($this->model ->isTypeClose ()) {
$prev;
if ($this->model->type == AccountState::TYPE_CLOSE) {
if (isset ( $this->model->prev_state )) {
@@ -41,28 +41,28 @@ class AccountStateMail extends Object {
}
$this->details = new DailyListing();
$this->details->loadAccountState ( $this->model );
$this->details->readModeAccountState();
// $this->details->readTotalEasy ();
// $this->details->readTotalDetailed ();
// $this->details->readTotalMedium ();
}
}
public function sednMail(){
$subject = $this->model->isTypeOpen() ? "Kassza nyitás " : "Kassza zárás";
$subject .= " - " . $this->user->username ." - ". $this->account->name;
$this->message = \Yii::$app->mailer->compose('account_state', [
'model' => $this->model,
'details' => $this->details
]);
$this->attachPdf();
try{
$this->message->setFrom(\Yii::$app->params['infoEmail'])
->setTo( \Yii::$app->params['notify_mail'] )
@@ -71,21 +71,21 @@ class AccountStateMail extends Object {
}catch (\Exception $e){
\Yii::error("Nem sikerült elküldeni a kassza müvelet emailt");
}
}
protected function attachPdf(){
$mpdf=new \mPDF('utf-8', 'A4-L');
$mpdf->useSubstitutions=false;
$mpdf->simpleTables = true;
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
$mpdf->setFooter('{PAGENO} / {nb}');
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($this->controller->renderPartial("@common/views/account-state/account_state_pdf", [
'model' => $this->model,
'details' => $this->details
@@ -94,11 +94,11 @@ class AccountStateMail extends Object {
$dt= "_letrehozva_".date("Ymd_His"). "_" . $this->user->username;
$fn= $type .$dt.".pdf";
$content = $mpdf->Output($fn, 'S');
$this->message->attachContent($content, ['fileName' => $fn, 'contentType' => 'application/pdf']);
}
}
}