//批量下载简历
public function batch_resume()
{
require_once 'vendor/autoload.php';
$mpdfConfig = [
'mode' => 'utf-8',
'tempDir' => dirname(dirname($path)),
'format' => 'A4',
'useSubstitutions' => true,
'useAdobeCJK' => true,
'autoScriptToLang' => true,
'autoLangToFont' => true,
'mgl' => 150,
'mgr' => 150,
'mgt' => 160,
'mgb' => 160,
'mgh' => 90,
'mgf' => 90,
'orientation' => 'P'
];
$data = explode(',', $_GET['userids']);
foreach ($data as $userid) {
$where = array('userid' => $userid);
//申请声明
$res = $this->BaseModel->getone('mba_content_page', array('code' => 'index_statement'), $select = '*');
//学习方式
$project = $this->BaseModel->getkeyval('mba_project_info', 'state =1', 'id', 'title');
//基本信息
$basic = $this->BaseModel->getone('mba_user_basic', array('id' => $userid), '*');
$_SESSION['parentid'] = $basic['parentid'];
//用户信息
$user_info_field = $this->BaseModel->getmore('mba_user_field', "state =1 and find_in_set('" . $_SESSION['parentid'] . "',parentid) and `table` =1 ", '*', "sort asc");
$user_info = $this->BaseModel->getone('mba_user_info', $where);
//教育信息
$user_edu_field = $this->BaseModel->getmore('mba_user_field', "state =1 and find_in_set('" . $_SESSION['parentid'] . "',parentid) and `table` =2 ", '*', "sort asc");
$user_edu = $this->BaseModel->getone('mba_user_edu', $where);
// 获得最高奖励
$user_highest_field = $this->BaseModel->getmore('mba_user_field', "state =1 and find_in_set('" . $_SESSION['parentid'] . "',parentid) and `table` = 13", '*', "sort asc");
$user_highest = $this->BaseModel->getone('mba_user_highest', $where);
//工作信息
$user_work_field = $this->BaseModel->getmore('mba_user_field', "state =1 and find_in_set('" . $_SESSION['parentid'] . "',parentid) and `table` =3 ", '*', "sort asc");
$user_work = $this->BaseModel->getone('mba_user_work', $where);
//论述题信息
$user_discuss_field = $this->BaseModel->getmore('mba_user_field', "state =1 and find_in_set('" . $_SESSION['parentid'] . "',parentid) and `table` =4 and year=" . date('Y'), '*', "sort asc");
if (empty($field)) {
for ($i = date('Y') + 1; $i >= 2014; $i--) { //最近的论述题
$user_discuss_field = $this->BaseModel->getmore('mba_user_field', "state =1 and find_in_set('" . $_SESSION['parentid'] . "',parentid) and `table` =4 and year=" . $i, '*', "sort asc");
if ($user_discuss_field) break;
}
}
$user_discuss = $this->BaseModel->getone('mba_user_discuss', $where);
//附加问题
$user_question_field = $this->BaseModel->getmore('mba_user_field', "state =1 and find_in_set('" . $_SESSION['parentid'] . "',parentid) and `table` =5 ", '*', "sort asc");
$user_question = $this->BaseModel->getone('mba_user_question', $where);
//推荐人
$sql = "select * from mba_user_referees where userid = $userid order by id asc";
$user_referees = $this->BaseModel->getquery($sql);
$tjx = array();
foreach ($user_referees as $k => $v) {
$tjx[$k] = $this->BaseModel->getone('mba_user_tjx', array('userid' => $userid, 'email' => $v['email']), '*');
}
//其它教育信息
$user_edu_other_field = $this->BaseModel->getmore('mba_user_field', "state =1 and find_in_set('" . $_SESSION['parentid'] . "',parentid) and `table` =9 ", '*', "sort asc");
$user_edu_other = $this->BaseModel->getmore('mba_user_edu_other', $where);
//其它工作信息
$user_work_other_field = $this->BaseModel->getmore('mba_user_field', "state =1 and find_in_set('" . $_SESSION['parentid'] . "',parentid) and `table` =10 ", '*', "sort asc");
$user_work_other = $this->BaseModel->getmore('mba_user_work_other', $where);
$userapply = $this->BaseModel->getone('mba_user_apply', array('userid' => $userid), '*');
//批次
$advance = array();
if (!empty($userapply['adid'])) {
$advance = $this->BaseModel->getone('mba_advance_info', "id =" . $userapply['adid'], 'batchtype,addrs');
}
$field_ambition = $this->BaseModel->getmore('mba_user_field', "state =1 and find_in_set('" . $_SESSION['parentid'] . "',parentid) and `table` =12", '*', "sort asc");
$user_ambition = $this->BaseModel->getone('mba_user_ambition', $where);
$data = array('project' => $project, 'field_ambition' => $field_ambition, 'user_ambition' => $user_ambition, 'basic' => $basic, 'user_info_field' => $user_info_field, 'user_info' => $user_info, 'user_highest_field' => $user_highest_field, 'user_highest' => $user_highest, 'user_edu_field' => $user_edu_field, 'user_edu' => $user_edu, 'user_work_field' => $user_work_field, 'user_work' => $user_work, 'user_discuss_field' => $user_discuss_field, 'user_discuss' => $user_discuss, 'user_question_field' => $user_question_field, 'user_question' => $user_question, 'user_referees' => $user_referees, 'tjx' => $tjx, 'user_edu_other_field' => $user_edu_other_field, 'user_edu_other' => $user_edu_other, 'user_work_other_field' => $user_work_other_field, 'user_work_other' => $user_work_other, 'advance' => $advance, 'userapply' => $userapply,);
$html = $this->load->view('/Apply/previews', $data, true) ;
//var_dump($html);die;
$mpdf = new \Mpdf\Mpdf();
$mpdf->autoScriptToLang = true;//支持中文设置
$mpdf->autoLangToFont = true;//支持中文设置
$mpdf->WriteHTML($html);
mkdir('./uploads/resume/',0777);
$path = './uploads/resume/' . date('YmdHis') . '_' .$basic['name'] . '.pdf';
$path_data[] = $path;
$mpdf->Output($path, 'f');//保存pdf文件到指定目录
}
//压缩包文件名称
$filename = "resume.zip";
//压缩文件夹
$zip= new ZipArchive();
if($zip->open($filename, ZipArchive::CREATE)=== TRUE) {
foreach ($path_data as $item){
$zip -> addFile($item,basename($item));
}
$zip->close();
header("Cache-Control: max-age=0");
header("Content-Description: File Transfer");
header('Content-disposition: attachment; filename=' . basename($filename)); // 文件名
header("Content-Type: application/zip"); // zip格式的
header("Content-Transfer-Encoding: binary"); // 告诉浏览器,这是二进制文件
header('Content-Length: ' . filesize($filename)); // 告诉浏览器,文件大小
@readfile($filename);//输出文件;
// 删除服务器上的压缩包
unlink($filename);
foreach ($path_data as $item){
unlink('./uploads/resume/' .basename($item));
}
}else{
ajaxReturn('', '下载失败!', 0);
}
}
php 批量生成pdf 为压缩包进行下载输出
最新推荐文章于 2024-06-03 15:33:05 发布