196 lines
5.8 KiB
PHP
196 lines
5.8 KiB
PHP
<?php
|
||
//生成西部数据中心离线申请表
|
||
|
||
use Helpers\View as view;
|
||
|
||
require_once('fpdf/chinese-unicode.php');
|
||
require_once('fpdi/fpdi.php');
|
||
class ApplicantPDF extends FPDI
|
||
{
|
||
public $template;//模板文件的路径
|
||
public $heihetemplate;//模板文件的路径
|
||
public $data;//包含具体的数据,数组
|
||
public $fontsize=10;
|
||
public $pdflink;
|
||
|
||
function __construct()
|
||
{
|
||
parent::__construct();
|
||
//$this->AddUniGBhwFont('ugb','AdobeSongStd-Light-Acro');
|
||
}
|
||
function drawWestdc()
|
||
{
|
||
$pagecount = $this->setSourceFile($this->template);
|
||
$tplidx = $this->importPage(1);
|
||
$this->addPage();
|
||
$this->useTemplate($tplidx);
|
||
$this->SetFont('Courier','',$this->fontsize);
|
||
$this->setXY(62,41);
|
||
$this->Write($this->fontsize,$this->data['realname']);
|
||
$this->SetXY(34,55);
|
||
$this->MultiCell (166, 4, str_replace(";","\n",$this->data['westdclist']));
|
||
$this->setXY(30,100);
|
||
$this->MultiCell(166,4,trim($this->data['project']));
|
||
//$this->setXY(34,239);
|
||
//$this->Write($this->fontsize,$this->data['realname']);
|
||
$this->setXY(48,194);
|
||
$this->Write($this->fontsize,$this->data['unit']);
|
||
$this->setXY(36,209);
|
||
$this->Write($this->fontsize,$this->data['email']);
|
||
//$this->setXY(174,223);
|
||
//$this->Write($this->fontsize,$this->data['postcode']);
|
||
$this->setXY(38,201);
|
||
$this->Write($this->fontsize,$this->data['address']);
|
||
$this->setXY(112,209);
|
||
$this->Write($this->fontsize,$this->data['phone']);
|
||
$t=date("Y-m-d");
|
||
$this->setXY(160,209);
|
||
$this->Write($this->fontsize,$t);
|
||
}
|
||
function drawHeihe()
|
||
{
|
||
$pagecount = $this->setSourceFile($this->heihetemplate);
|
||
$tplidx = $this->importPage(1);
|
||
$this->addPage();
|
||
$this->useTemplate($tplidx);
|
||
$this->SetFont('ugb','',$this->fontsize);
|
||
$this->setXY(88,43);
|
||
$this->Write($this->fontsize,$this->data['realname']);
|
||
$this->SetXY(34,55);
|
||
$this->MultiCell (166, 4, str_replace(";","\n",$this->data['heihelist']));
|
||
$this->setXY(30,100);
|
||
$this->MultiCell(166,4,trim($this->data['project']));
|
||
//$this->setXY(34,239);
|
||
//$this->Write($this->fontsize,$this->data['realname']);
|
||
$this->setXY(32,223);
|
||
$this->Write($this->fontsize,$this->data['unit']);
|
||
$this->setXY(112,223);
|
||
$this->Write($this->fontsize,$this->data['email']);
|
||
$this->setXY(174,223);
|
||
$this->Write($this->fontsize,$this->data['postcode']);
|
||
$this->setXY(32,230);
|
||
$this->Write($this->fontsize,$this->data['address']);
|
||
$this->setXY(112,230);
|
||
$this->Write($this->fontsize,$this->data['phone']);
|
||
$t=date("Y-m-d");
|
||
$this->setXY(174,230);
|
||
$this->Write($this->fontsize,$t);
|
||
}
|
||
function addRef($mds)
|
||
{
|
||
$this->addPage();
|
||
$this->SetFont('Times','B',20);
|
||
$this->ln();
|
||
$this->Cell(0,0,'Attachment: Data Citation',0,2,'C');
|
||
$this->setY(30);
|
||
foreach($mds as $i=>$md)
|
||
{
|
||
$this->SetFont('Times','',12);
|
||
$this->Write(5,($i+1).'. '.$md['title']);
|
||
$this->ln();
|
||
if ($md['reference'])
|
||
{
|
||
$this->Write(5,'[Citation] '.$md['reference']);
|
||
$this->ln();
|
||
if (!empty($md['publish_year']))
|
||
{
|
||
$this->Write(5,'[Data citation] '.str_replace('"','',substr($md['author_en'],1,-1)).'. '.$md['title_en']
|
||
.'. '.$md['publisher_en'].', '.(empty($md['ts_published'])?$md['publish_year']:date('Y',strtotime($md['ts_published']))).'. doi:'.$md['datadoi']);
|
||
$this->ln();
|
||
}
|
||
} elseif ($md['citation'])
|
||
{
|
||
$this->Write(5,'[Citation] '.$md['citation']);
|
||
$this->ln();
|
||
if (!empty($md['publish_year']) && !strpos($md['citation'],$md['datadoi']))
|
||
{
|
||
$this->Write(5,'[Data citation] '.str_replace('"','',substr($md['author_en'],1,-1)).'. '.$md['title_en']
|
||
.'. '.$md['publisher_en'].', '.(empty($md['ts_published'])?$md['publish_year']:date('Y',strtotime($md['ts_published']))).'. doi:'.$md['datadoi']);
|
||
$this->ln();
|
||
}
|
||
}
|
||
if ($md['suppinfo'] || $md['fund'])
|
||
{
|
||
$this->SetFont('Times','I',10);
|
||
$p=(!empty($md['fund']))?$md['fund']:$md['suppinfo'];
|
||
$this->Write(5,'[Funding] '.$p);
|
||
$this->ln();
|
||
}
|
||
$this->ln();
|
||
}
|
||
}
|
||
function addSecurity($template_file)
|
||
{
|
||
$pagecount = $this->setSourceFile($template_file);
|
||
$tplidx = $this->importPage(1);
|
||
$this->addPage();
|
||
$this->useTemplate($tplidx);
|
||
$this->SetFont('ugb','B',14);
|
||
$this->setXY(46,51);
|
||
$this->Write(10,$this->data['realname']);
|
||
$this->SetFont('ugb','',12);
|
||
$this->setXY(122,194);
|
||
$this->Write(10,$this->data['realname']);
|
||
$this->setXY(122,201);
|
||
$this->Write($this->fontsize,$this->data['address']);
|
||
$this->setXY(122,208);
|
||
$this->Write($this->fontsize,$this->data['phone']);
|
||
$this->setXY(122,215);
|
||
$this->Write($this->fontsize,$this->data['email']);
|
||
$t=date("Y-m-d");
|
||
$this->setXY(32,242);
|
||
$this->Write($this->fontsize,$t);
|
||
$this->setXY(122,242);
|
||
$this->Write($this->fontsize,$t);
|
||
}
|
||
|
||
//如果有dataservice内容,则添加
|
||
public function addSelection($data)
|
||
{
|
||
$line = array();
|
||
foreach($data as $k=>$v)
|
||
{
|
||
if(!empty($v['selection']))
|
||
{
|
||
$selection = json_decode($v['selection'],true);
|
||
$thisline = "".$v['title']."\r\n";
|
||
foreach($selection as $s)
|
||
{
|
||
$thisline .= "".$s['name'].": ";
|
||
if($s['var'] == -1)
|
||
{
|
||
$thisline .= "All";
|
||
}else{
|
||
foreach($s['var'] as $var)
|
||
{
|
||
$thisline.= $var["nameview"]."/";
|
||
}
|
||
}
|
||
$thisline .= $s['starttime'] ." - ". $s['endtime'];
|
||
$thisline .= "\r\n\r\n";
|
||
}
|
||
$line[] = $thisline."";
|
||
}
|
||
}
|
||
|
||
if(count($line) < 1)
|
||
{
|
||
return;
|
||
}
|
||
|
||
$this->addPage();
|
||
$this->SetFont('ugb','B',20);
|
||
$this->ln();
|
||
$this->Cell(0,0,'Attachment: Data Subsets',0,2,'C');
|
||
$this->setY(30);
|
||
|
||
foreach($line as $k=>$v)
|
||
{
|
||
$this->SetFont('ugb','',10);
|
||
$this->Write(5,($k+1).'. ' .$v ."\r\n");
|
||
$this->ln();
|
||
}
|
||
|
||
}
|
||
}
|
||
?>
|