public function make($cid) { $this->id = rand(0, 999999); //$this->iniArr=array('b110'=>0,'b100'=>0,'m100'=>0,'c100'=>0,'d100'=>0,'d110'=>0,'d120'=>0,); //$this->docArr=array(0=>0,305=>0,300=>0,); $bkmv = ''; //$this->line=1; //$yiidatetimesec=Yii::$app->locale->getDateFormat('yiidatetimesec'); //$phpdbdatetime=Yii::$app->locale->getDateFormat('phpdbdatetime'); $from_date = $this->from_date . " 00:00:00"; $to_date = $this->to_date . " 23:59:59"; //$types=array(3,4,9,11,13,14); //accounts $accounts = Accounts::find()->All(); $record = array('id' => 'B110', 'name' => OpenFormatType::getDesc('B110'), 'count' => 0); foreach ($accounts as $account) { $this->line++; $bkmv .= $account->openfrmt($this->line, $from_date, $to_date); $record['count']++; } $this->iniArr[] = $record; //items $items = Item::find()->All(); $record = array('id' => 'M100', 'name' => OpenFormatType::getDesc('M100'), 'count' => 0); foreach ($items as $item) { $this->line++; $bkmv .= $item->openfrmt($this->line, $from_date, $to_date); $record['count']++; } $this->iniArr[] = $record; // //transactions $transactions = Transactions::find()->where(['BETWEEN', 'valuedate', $from_date, $to_date])->All(); $record = array('id' => 'B100', 'name' => OpenFormatType::getDesc('B100'), 'count' => 0); foreach ($transactions as $transaction) { $this->line++; $bkmv .= $transaction->openfrmt($this->line, $from_date, $to_date); $record['count']++; } $this->iniArr[] = $record; //docs $docs = Docs::find()->where(['BETWEEN', 'due_date', $from_date, $to_date])->All(); //OpenFormatType::getDesc('C100') $record = array('id' => 'C100', 'name' => OpenFormatType::getDesc('C100'), 'count' => 0); $d110 = array('id' => 'D110', 'name' => OpenFormatType::getDesc('D110'), 'count' => 0); $d120 = array('id' => 'D120', 'name' => OpenFormatType::getDesc('D120'), 'count' => 0); foreach ($docs as $doc) { if ($doc->docType->openformat != '0') { $this->line++; $bkmv .= $doc->openfrmt($this->line, $from_date, $to_date); foreach ($doc->docDetailes as $detial) { $this->line++; $bkmv .= $detial->openfrmt($this->line, $from_date, $to_date); $d110['count']++; } foreach ($doc->docCheques as $detial) { $this->line++; $bkmv .= $detial->openfrmt($this->line, $from_date, $to_date); $d120['count']++; } $type = $doc->OpenfrmtType(); $this->docArr[$type] = isset($this->docArr[$type]) ? $this->docArr[$type] + 1 : 0; $this->docSumArr[$type] = isset($this->docSumArr[$type]) ? $this->docSumArr[$type] + $doc->total : $doc->total; $record['count']++; } } $this->iniArr[] = $record; $this->iniArr[] = $d110; $this->iniArr[] = $d120; $company = \app\models\Settings::findOne(['company.name']); //A100 $bkmv = $company->a100(1, $this->id, $from_date, $to_date) . $bkmv; //Z900 $bkmv = $bkmv . $company->z900($this->line + 1, $this->id, $this->line + 1); $bkmvFile = new Files(); $bkmvFile->name = 'bkmvdata.txt'; $bkmvFile->path = 'openformat/'; // $bkmvFile->expire = 360; $bkmvFile->save(); $bkmvFile->writeFile($bkmv); $this->bkmvId = $bkmvFile->id; //A000 $ini = $company->a000(1, $this->id, $this->line + 1, $from_date, $to_date); foreach ($this->iniArr as $line) { $ini .= $line['id'] . sprintf("%015d", $line['count']) . "\r\n"; } //Z $iniFile = new Files(); $iniFile->name = 'ini.txt'; $iniFile->path = 'openformat/'; // $iniFile->expire = 360; $iniFile->save(); $iniFile->writeFile($ini); $this->iniId = $iniFile->id; return $this->id; }