$downloadurl = [
'url' => '/web/files/' . $file,
];
return json_encode($downloadurl);
.then((data) => {
window.open(data.url);
})
error: (function(e) {
console.log(e);
})
public function actionPrint($id)
{
$model = Order::findOne($id);
$orders = $model->products;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
if(Yii::$app->request->isGet){
if(Yii::$app->request->get('pdf') == 'bill'){
$doc = new \PhpOffice\PhpWord\TemplateProcessor(Yii::getAlias('@webroot').'/files/print_temp/bills_temp.docx');
$doc->setValue('d_date', date('d.m.Y'));
$doc->setValue('c_inn', $model->client->inn);
$doc->setValue('c_name', $model->client->name);
$str = 'num';
$doc->cloneRow('num', count($orders));
$i=0;
foreach ($orders as $product){
$doc->setValue('num#'.$i, $i+1);
$doc->setValue('p_name#'.$i, $product['description']);
$doc->setValue('p_count#'.$i, $product['count']);
$doc->setValue('p_price#'.$i, $product['price']);
$doc->setValue('p_sum#'.$i, ($product['price'] * $product['count']));
$i++;
}
$dir = '/files/';
$files_dir = Yii::getAlias('@webroot')."/".$dir;
$file = str_replace("/","-", "Счет ".date("d-m-Y")).".docx";
$doc->saveAs($files_dir.$file);
}
}
return true;
}
$sql = "UPDATE lids SET stat_lids=:stat WHERE id_lids=:id";
$sth=$db->prepare($sql);
$sth->bindParam(':stat', $stat);
$sth->bindParam(':id', $id);
$sth->execute();
$sth=$db->prepare("UPDATE lids SET stat_lids=:stat WHERE id_lids=:id");
$sth->bindParam(':stat', $stat);
$sth->bindParam(':id', $id);
$sth->execute();
$mail_login = "mymail";
$mail_password = "mail password";
$mail_imap = "{imap.site.ru/imap/novalidate-cert/ssl/norsh/user=name_user}INBOX";
$mbox = imap_open($mail_imap, $mail_login, $mail_password, NULL, 1, array('DISABLE_AUTHENTICATOR' => 'GSSAPI'));
$str = imap_errors(); print_r($str);
echo $str;
$mails = imap_search($mbox, 'UNSEEN');