//导出成交确认函
public function outputH(){
$start_time1 = strtotime($_POST['start_time1']);
$end_time1 = strtotime($_POST['end_time1']);
$project_id1 = $_POST['project_id1'];
$map['group_purchase_confirm_time'] = array("gt",$start_time1);
$map['group_purchase_confirm_time'] = array("lt",$end_time1);
$map['project_id'] = array("eq",$project_id1);
$model = M('group_purchase');
$res = $model->field("count(id) as total,sum(group_purchase_expenses) as tfee")->where($map)->select();
$project_model = M("project");
$p_res = $project_model->find($project_id1);
$arr['total'] = $res[0]['total'];
$arr['tfee'] = $res[0]['tfee'];
$arr['buy_start_time'] = date('Y年m月d日',$p_res['confirm_buy_start_time']);
$arr['buy_end_time'] = date('Y年m月d日',$p_res['confirm_buy_end_time']);
$arr['start_s'] = date('Y年m月d日',$start_time1);
$arr['end_s'] = date('Y年m月d日',$end_time1);
$arr['project_name'] = $p_res['project_name'];
//引入wordphp核心文件
require './ThinkPHP/Library/Vendor/PHPWord/PHPWord.php';
require './ThinkPHP/Library/Vendor/PHPWord/PHPWord/IOFactory.php';
// New Word Document
$PHPWord = new \PHPWord();
// New portrait section
$section = $PHPWord->createSection();
// Add text elements
$str = " ".$arr['project_name']."项目,与腾讯房产于".$arr['buy_start_time']."至".$arr['buy_end_time']."开展腾讯电商团购合作,".$arr['start_s']."至".$arr['end_s']."内,共计售出房屋". $arr['total']."套,成交明细见附件,收取服务费合计".$arr['tfee']."元,特此证明。";
$str5 = " 本确认函中的房源均已通过网签为确认标准,经双方授权代表签字后生效作为收款确认依据。且一旦签字盖章,乙方将不再承担该房源后续的电商团购费的退款责任。";
$str1 = "甲 方: 乙 方:";
$str2 = "授权代表签字: 授权代表签字:";
$str3 = "盖章: 盖章:";
$str4 = "签约时间:20 年 月 日 签约时间:20 年 月 日";
$title = iconv('utf-8','GB2312//IGNORE','腾讯电商合作成交签约确认函');
$section->addText($title,'rStyle','pStyle');
$section->addTextBreak(2);
$section->addText(iconv('utf-8','GB2312//IGNORE',$str),'cOntent');
$section->addTextBreak(2);
$section->addText(iconv('utf-8','GB2312//IGNORE',$str5),'cOntent');
$section->addTextBreak(2);
$section->addText(iconv('utf-8','GB2312//IGNORE',$str1),'cOntent');
$section->addText(iconv('utf-8','GB2312//IGNORE',$str2),'cOntent');
$section->addText(iconv('utf-8','GB2312//IGNORE',$str3),'cOntent');
$section->addText(iconv('utf-8','GB2312//IGNORE',$str4),'cOntent');
$section->addTextBreak(2);
// $section->addText('I am inline styled.', array('name'=>'Verdana', 'color'=>'006699'));
$section->addTextBreak(2);
$PHPWord->addFontStyle('cOntent', array('bold'=>false, 'size'=>12));
$PHPWord->addFontStyle('rStyle', array('bold'=>true, 'italic'=>false, 'size'=>16,'align'=>'center'));
$PHPWord->addParagraphStyle('pStyle', array('align'=>'center', 'spaceAfter'=>100));
// $section->addText('I am styled by two style definitions.', 'rStyle', 'pStyle');
// $section->addText('I have only a paragraph style definition.', null, 'pStyle');
// Save File
$objWriter = \PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('./Public/电商成交确认函'.date("YmdHis").'.docx');
echo './Public/电商成交确认函'.date("YmdHis").'.docx'; //返回生成的word文件的路径
}
//将生成的文件用次函数进行下载
public function download_file(){
$file = $_GET['url'];
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename=电商成交确认函.docx');
header("Content-Length: ". filesize($file));
readfile($file);
}