для отправки письма:
Код: Выделить всё
<?php
use yii\db\ActiveRecord;
use yii\db\Query;
use app\models\MailerForm;
$this->title = 'Письмо';
$this->params['breadcrumbs'][] = $this->title;
$dannie = $_POST;
$ws=new MailerForm();
if(isset($dannie['process']) && $dannie['process'] === 'go') {
//-------------------------------------------------------------------------------------------------------
$zip = new ZipArchive();
$outputFilename = 'tst.docx';
print"<hr> Пришло: ";
echo $dannie;
print "<br>";
print_r($dannie);
print "<br>";
echo $num = $dannie['num'];
$komy = $dannie['komy'];
$obra = $dannie['obra'];
$text = $dannie['text'];
$tema = $dannie['tema'];
print"<hr> ";
print "<br>";
echo $num;
print "<br>";
echo $komy;
print "<br>";
print "<br>";
$dates = date("Y-m-d");
$newfile = "msg/$num-$dates.docx";
$file = 'blank_pismo.docx';
if (!copy($file, $newfile)) {
echo "не удалось скопировать $file...\n";
}
print"<hr> ";
$inputFilename = $newfile;
$one=htmlspecialchars_decode($_POST['tema']);
$two=htmlspecialchars_decode($_POST['text']);
$three=$ws->getNumposl();
$dates = date("Y-m-d");
Yii::$app->db->createCommand("INSERT INTO ishodpisma (`tema`,`text`,`num`,`date`) VALUES ('$tema','$text','$num','$dates')")->execute();
if($result == 'true')
{echo getSave($_POST);}
else{echo "Ваши данные не добавлены";}
if ($zip->open($inputFilename, ZipArchive::CREATE)!==TRUE) {
echo "Cannot open $filename :( "; die;
}
// Fetch the document.xml file from the word subdirectory in the archive.
$xml = $zip->getFromName('word/document.xml');
// Replace the tokens.
$xml = str_replace('{NUM}',$num, $xml);
$xml = str_replace('{KOMY}',$komy, $xml);
$xml = str_replace('{OBR}',$obra, $xml);
$xml = str_replace('{TEXT}',$text, $xml);
$xml = str_replace('{TEMA}',$tema, $xml);
$xml = str_replace('{DATA}',$dates, $xml);
// Write back to the document and close the object
if ($zip->addFromString('word/document.xml', $xml)) { echo 'File written!'; }
else { echo 'File not written. Go back and add write permissions to this folder!l'; }
$zip->close();
//-------------------------------------------------------------------------------------------------------
}
else{
$ws->getNumposl();
$dates = date("d-m-Y");
?>
<div class="site-contact">
<form method="POST" action="">
<?php echo"<p>Номер <input name=\"num\" type=\"text\" value=".$ws->getNumposl()." readonly></p>"; ?>
<p>Кому <input name="komy" type="text" value="Пипкину"></p>
<p>Обращение<input name="obra" type="text" value="Глубокоуважаемый"></p>
<p>Сообщение<input name="text" type="text" size="100" value="текст большой текст" ></p>
<p>Тема Сообщеиия<input name="tema" type="text" value="Тема"></p>
<?php echo"<p>Дата<input name='dates' type='text' value=".$dates." readonly></p>"; ?>
<p><input name="process" type="hidden" value="go"></p>
<input type="submit" value="Сохранить">
</form>
</div>
<?
}
?>
Код: Выделить всё
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\db\ActiveRecord;
use yii\db\Query;
use app\models\Slugebka;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Служебка');
$this->params['breadcrumbs'][] = $this->title;
$dannie = $_POST;
$ws=new Slugebka();
if(isset($dannie['process']) && $dannie['process'] === 'goo') {
//-------------------------------------------------------------------------------------------------------
$zip = new ZipArchive();
$outputFilename = 'tst.docx';
print"<hr> Пришло: ";
echo $dannie;
print "<br>";
print_r($dannie);
print "<br>";
echo
$num = $dannie['num'];
$text = $dannie['text'];
$tema = $dannie['tema'];
print"<hr> ";
print "<br>";
echo $num;
print "<br>";
echo $text;
print "<br>";
echo $tema;
print "<br>";
print "<br>";
$dates = date("Y-m-d");
$newfile = "mssg/$num-$dates.docx";
$file = 'blank_slugebka.docx';
if (!copy($file, $newfile)) {
echo "не удалось скопировать $file...\n";
}
print"<hr> ";
$inputFilename = $newfile;
$one=htmlspecialchars_decode($_POST['tema']);
$two=htmlspecialchars_decode($_POST['text']);
$three=$ws->getNumposl();
$dates = date("Y-m-d");
Yii::$app->db->createCommand("INSERT INTO Slugebka (`num`,`date`,`tema`,`text`) VALUES ('$num','$dates','$tema','$text')")->execute();
if($result == 'true')
{echo "Ваши данные успешно добавлены";}
else{echo "Ваши данные не добавлены";}
if ($zip->open($inputFilename, ZipArchive::CREATE)!==TRUE) {
echo "Cannot open $filename :( "; die;
}
// Fetch the document.xml file from the word subdirectory in the archive.
$xml = $zip->getFromName('word/document.xml');
// Replace the tokens.
$xml = str_replace('{NUM}',$num, $xml);
$xml = str_replace('{DATA}',$dates, $xml);
$xml = str_replace('{TEMA}',$token6, $xml);
$xml = str_replace('{TEXT}',$token4, $xml);
// Write back to the document and close the object
if ($zip->addFromString('word/document.xml', $xml)) { echo 'File written!'; }
else { echo 'File not written. Go back and add write permissions to this folder!l'; }
$zip->close();
//-------------------------------------------------------------------------------------------------------
}
else{
$ws->getNumposl();
$dates = date("d-m-Y");
?>
<div class="site-contact">
<form method="POST" action="">
<?php echo"<p>Номер <input name=\"num\" type=\"text\" value=".$ws->getNumposl()." readonly></p>"; ?>
<?php echo"<p>Дата<input name='dates' type='text' value=".$dates." readonly></p>"; ?>
<p>Тема Сообщеиия<input name="token6" type="text" value="Тема"></p>
<p>Сообщение<input name="token4" class="token5" type="text" size="100" value="текст большой текст" ></p>
<p><input name="process" type="hidden" value="goo"></p>
<input type="submit" value="Сохранить">
</form>
</div>
<?
}
?>