365 lines
16 KiB
PHP
365 lines
16 KiB
PHP
<?php
|
||
|
||
namespace app\api\controller;
|
||
|
||
use think\Controller;
|
||
use think\Db;
|
||
use TCPDF;
|
||
|
||
class Reviewer extends Controller {
|
||
|
||
protected $user_obj = '';
|
||
protected $user_reviewer_obj = '';
|
||
protected $journal_obj = '';
|
||
protected $reviewer_major_obj = '';
|
||
protected $reviewer_to_journal_obj = '';
|
||
protected $user_reviewer_info_obj = '';
|
||
protected $user_log_obj = '';
|
||
protected $article_obj = '';
|
||
protected $article_file_obj = '';
|
||
protected $article_reviewer_obj = '';
|
||
protected $article_reviewer_file_obj = '';
|
||
protected $article_reviewer_question_obj = '';
|
||
|
||
//put your code here
|
||
public function __construct(\think\Request $request = null) {
|
||
parent::__construct($request);
|
||
$this->user_obj = Db::name('user');
|
||
$this->user_reviewer_obj = Db::name('user_reviewer_apply');
|
||
$this->journal_obj = Db::name('journal');
|
||
$this->reviewer_major_obj = Db::name('reviewer_major');
|
||
$this->reviewer_to_journal_obj = Db::name('reviewer_to_journal');
|
||
$this->user_reviewer_info_obj = Db::name('user_reviewer_info');
|
||
$this->user_log_obj = Db::name('user_log');
|
||
$this->article_obj = Db::name('article');
|
||
$this->article_file_obj = Db::name('article_file');
|
||
$this->article_reviewer_obj = Db::name('article_reviewer');
|
||
$this->article_reviewer_file_obj = Db::name('article_reviewer_file');
|
||
$this->article_reviewer_question_obj = Db::name('article_reviewer_question');
|
||
}
|
||
|
||
/**
|
||
* 获取文章审稿实例列表(审稿人)
|
||
*/
|
||
public function getReviewerList() {
|
||
$data = $this->request->post();
|
||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||
$reviewer_info = $this->user_obj->where('account', $data['username'])->find();
|
||
$res = $this->article_reviewer_obj->field('t_article_reviewer.*,t_article.title article_title,t_journal.title journal_title,t_article.accept_sn accept_sn')
|
||
->join('t_article', 't_article_reviewer.article_id = t_article.article_id', 'LEFT')
|
||
->join('t_journal', 't_article.journal_id = t_journal.journal_id', 'LEFT')
|
||
->where('t_article_reviewer.reviewer_id', $reviewer_info['user_id'])
|
||
->order('t_article_reviewer.state')
|
||
->limit($limit_start, $data['pageSize'])
|
||
->select();
|
||
$count = $this->article_reviewer_obj->where('t_article_reviewer.reviewer_id', $reviewer_info['user_id'])->count();
|
||
return json(['code' => 0, 'data' => $res, 'total' => $count]);
|
||
}
|
||
|
||
/**
|
||
* 获取审稿人详情
|
||
*/
|
||
public function getReviewerDetail(){
|
||
$uid = $this->request->post('rid');
|
||
//获取基本信息
|
||
$base_info = $this->user_obj->join('t_user_reviewer_info','t_user.user_id = t_user_reviewer_info.reviewer_id')->where('t_user.user_id',$uid)->find();
|
||
//增加major
|
||
$major_res = $this->reviewer_major_obj->where('major_id',$base_info['major'])->column('title');
|
||
$base_info['major_title'] = $major_res?$major_res[0]:'';
|
||
$cmajor_res = $this->reviewer_major_obj->where('major_id',$base_info['cmajor'])->column('title');
|
||
$base_info['cmajor_title'] = $cmajor_res?$cmajor_res[0]:'';
|
||
|
||
return json(['data'=>$base_info]);
|
||
}
|
||
|
||
/**
|
||
* 更改审稿人信息
|
||
*/
|
||
public function editReviewer(){
|
||
$data = $this->request->post();
|
||
$this->user_reviewer_info_obj->where('reviewer_info_id',$data['reviewer_info_id'])->update(['major'=>$data['major'],'cmajor'=>$data['cmajor']]);
|
||
return json(['code'=>0]);
|
||
}
|
||
|
||
|
||
/**
|
||
* 上传/修改文章审核实例详情两个文件(编辑,审稿人)
|
||
*/
|
||
public function articleReviewerUpSubmit($type) {
|
||
//接受参数,查询信息
|
||
$data = $this->request->post();
|
||
$artrev_info = $this->article_reviewer_obj->where('art_rev_id', $data['artrevid'])->find();
|
||
$article_info = $this->article_obj->where('article_id',$artrev_info['article_id'])->find();
|
||
$editor_info = $this->user_obj->where('user_id',$article_info['editor_id'])->find();
|
||
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
|
||
if ($type == 'editor') {
|
||
$up_data['editor_act'] = 1;
|
||
$user_msg_url = '/reviewerArticleDetail?id='.$data['artrevid'];
|
||
$user_info = $this->user_obj->where('account', $data['editor'])->find();
|
||
} else {
|
||
$up_data['reviewer_act'] = 1;
|
||
$user_msg_url = '/articleReviewerDetail?id='.$data['artrevid'];
|
||
$user_info = $this->user_obj->where('user_id', $artrev_info['reviewer_id'])->find();
|
||
}
|
||
|
||
//上传
|
||
self::save_article_reviewer_file($data['artrevid'], $user_info['user_id'], $user_info['account'], $data['articlefile'], 'articlefile');
|
||
if ($data['articlezip'] != '') {
|
||
self::save_article_reviewer_file($data['artrevid'], $user_info['user_id'], $user_info['account'], $data['articlezip'], 'articlezip');
|
||
}
|
||
|
||
//更新实例状态
|
||
$this->article_reviewer_obj->where('art_rev_id',$data['artrevid'])->update($up_data);
|
||
|
||
//记录userlog
|
||
$log_data['user_id'] = $user_info['user_id'];
|
||
$log_data['type'] = 3;
|
||
$log_data['content'] = $user_info['account'] . "(" . $user_info['realname'] . "),更改了一篇文章审稿实例:(" . $article_info['title'] . ")的状态,更改时间是:" . date('Y-m-d H:i:s', time());
|
||
$log_data['ctime'] = time();
|
||
$this->user_log_obj->insert($log_data);
|
||
|
||
//发送email提醒
|
||
if ($type != 'editor') {
|
||
$tt = 'Dear editor,<br>';
|
||
$tt .= 'Please check the new comments from the reviewer.';
|
||
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt,$journal_info['email'],$journal_info['epassword']);
|
||
}
|
||
|
||
//保存usermsg
|
||
add_usermsg($type == 'editor'?$artrev_info['reviewer_id']:$article_info['editor_id'], 'New status of the manuscript', $user_msg_url);
|
||
|
||
return json(['code' => 0]);
|
||
}
|
||
|
||
/**
|
||
* 获取文章审稿实例文件列表
|
||
*/
|
||
public function getFilelistByID() {
|
||
$rev_id = $this->request->post('revid');
|
||
$where['art_rev_id'] = $rev_id;
|
||
$res = $this->article_reviewer_file_obj->where($where)->select();
|
||
$frag = [];
|
||
foreach ($res as $v) {
|
||
$frag[$v['type_name']][] = $v;
|
||
}
|
||
return json($frag);
|
||
}
|
||
|
||
/**
|
||
* 获取文章信息列表
|
||
*/
|
||
public function getAFilelistByID(){
|
||
$rev_id = $this->request->post('revid');
|
||
$article_rev_info = $this->article_reviewer_obj->where('art_rev_id',$rev_id)->find();
|
||
$file_list = $this->article_file_obj->where('article_id',$article_rev_info['article_id'])->where('type_name','manuscirpt')->order('file_id desc')->limit(1)->select();
|
||
return json(['data'=>$file_list]);
|
||
}
|
||
|
||
public function getBFilelistByID(){
|
||
$rev_id = $this->request->post('revid');
|
||
$article_rev_info = $this->article_reviewer_obj->where('art_rev_id',$rev_id)->find();
|
||
$file_list = $this->article_file_obj->where('article_id',$article_rev_info['article_id'])->where('type_name','picturesAndTables')->order('file_id desc')->limit(1)->select();
|
||
return json(['data'=>$file_list]);
|
||
}
|
||
|
||
/**
|
||
* 获取文章审稿实例详情(审稿人,编辑)
|
||
*/
|
||
public function getartrevdate() {
|
||
//接受参数
|
||
$data = $this->request->post();
|
||
|
||
//查询实例数据
|
||
$res = $this->article_reviewer_obj->field('t_article_reviewer.*,t_article.title article_title,t_article.accept_sn accept_sn,t_user.account account')
|
||
->join('t_article', 't_article.article_id = t_article_reviewer.article_id', 'LEFT')
|
||
->join('t_user', 't_user.user_id = t_article_reviewer.reviewer_id', 'LEFT')
|
||
->where('t_article_reviewer.art_rev_id', $data['revid'])
|
||
->find();
|
||
|
||
//更改实例状态(消息提醒)
|
||
if($data['human']=='editor'){
|
||
$up_data['reviewer_act'] = 0;
|
||
}else{
|
||
$up_data['editor_act'] = 0;
|
||
}
|
||
$this->article_reviewer_obj->where('art_rev_id', $data['revid'])->update($up_data);
|
||
|
||
return json($res);
|
||
}
|
||
|
||
/**
|
||
* 提交问卷(审稿人)
|
||
*/
|
||
public function questionSubmit() {
|
||
//接受参数,查询基础数据
|
||
$data = $this->request->post();
|
||
|
||
$art_rev_info = $this->article_reviewer_obj->where('art_rev_id',$data['art_rev_id'])->find();
|
||
$article_info = $this->article_obj->where('article_id',$art_rev_info['article_id'])->find();
|
||
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
|
||
$editor_info = $this->user_obj->where('user_id',$article_info['editor_id'])->find();
|
||
//组合insert数据,存储
|
||
$insert_data['art_rev_id'] = $data['art_rev_id'];
|
||
$insert_data['qu1'] = $data['qu1'];
|
||
$insert_data['qu2'] = $data['qu2'];
|
||
$insert_data['qu3'] = $data['qu3'];
|
||
$insert_data['qu4'] = $data['qu4'];
|
||
$insert_data['qu5'] = $data['qu5'];
|
||
$insert_data['qu6'] = $data['qu6'];
|
||
$insert_data['qu7'] = $data['qu7'];
|
||
$insert_data['qu8'] = $data['qu8'];
|
||
$insert_data['qu9'] = $data['qu9']?1:0;
|
||
$insert_data['qu9_contents'] = $data['qu9contents'];
|
||
$insert_data['qu10'] = $data['qu10']?1:0;
|
||
$insert_data['qu10_contents'] = $data['qu10contents'];
|
||
$insert_data['qu11'] = $data['qu11']?1:0;
|
||
$insert_data['qu11_contents'] = $data['qu11contents'];
|
||
$insert_data['qu12'] = $data['qu12']?1:0;
|
||
$insert_data['qu12_contents'] = $data['qu12contents'];
|
||
$insert_data['qu13'] = $data['qu13']?1:0;
|
||
$insert_data['qu13_contents'] = $data['qu13contents'];
|
||
$insert_data['qu14'] = $data['qu14']?1:0;
|
||
$insert_data['qu14_contents'] = $data['qu14contents'];
|
||
$insert_data['qu15'] = $data['qu15']?1:0;
|
||
$insert_data['qu15_contents'] = $data['qu15contents'];
|
||
$insert_data['rated'] = $data['rated'];
|
||
$insert_data['recommend'] = $data['recommend'];
|
||
$insert_data['other'] = $data['other'];
|
||
$insert_data['confidential'] = $data['confident'];
|
||
$insert_data['comments'] = $data['comment'];
|
||
if ($data['rev_qu_id'] == '') {//新增
|
||
$insert_data['ctime'] = time();
|
||
$res = $this->article_reviewer_question_obj->insert($insert_data);
|
||
} else {//更新
|
||
$res = $this->article_reviewer_question_obj->where('rev_qu_id', $data['rev_qu_id'])->update($insert_data);
|
||
}
|
||
|
||
//根据recommend问题,改变此实例的状态,并且更改act消息提醒状态
|
||
if ($data['recommend'] == 1) {
|
||
$artrevstate = 3;
|
||
} else if ($data['recommend'] == 2) {
|
||
$artrevstate = 1;
|
||
} else {
|
||
$artrevstate = 2;
|
||
}
|
||
$this->article_reviewer_obj->where('art_rev_id', $data['art_rev_id'])->update(['state' => $artrevstate,'reviewer_act'=>1]);
|
||
//文章是从初始状态到其他状态,增加审稿人成功审核次数
|
||
if($art_rev_info['state']==0){
|
||
$this->user_obj->where('user_id',$art_rev_info['reviewer_id'])->setInc('rs_num');
|
||
}
|
||
|
||
//记录log
|
||
|
||
//生成pdf文件
|
||
$reviewer_pdf = self::pdftest($journal_info['title']);
|
||
|
||
//发送email->编辑
|
||
$tt = 'Dear editor,<br>';
|
||
$tt .= 'Please check the new comments from the reviewer.<br>';
|
||
$tt .= 'Journal:'.$journal_info['title'].' and article title:'.$article_info['title'];
|
||
sendEmail($editor_info['email'], $journal_info['title'], $journal_info['title'], $tt,$journal_info['email'],$journal_info['epassword']);
|
||
|
||
//发送email感谢reviewer并携带附件
|
||
$reviewer_info = $this->user_obj->where('user_id',$art_rev_info['reviewer_id'])->find();
|
||
$tt1 = 'You have reviewed 1 submission in the journal '.$journal_info['title'].' during '.date('Y').'.Thank you for your support to our journal. This contribution is greatly appreciated.<br><br>';
|
||
$tt1 .= 'Regards<br>Editorial Office<br>'.$journal_info['title'].'<br><br>';
|
||
$tt1 .= 'Contact us<br>TMR Publishing Group Address: 11 Cockle Bay Rd, Cockle Bay, Auckland 2014, New Zealand<br>Telephone: +64 02108293806<br>E-mail: publisher@tmrjournals.com';
|
||
sendEmail($reviewer_info['email'],'Your contribution is greatly appreciated', $journal_info['title'], $tt1,$journal_info['email'],$journal_info['epassword'],$reviewer_pdf);
|
||
//记录usermsg
|
||
add_usermsg($article_info['editor_id'], 'Feedback questionnaire be unloaded.', '/articleReviewerDetail?id='.$data['art_rev_id']);
|
||
|
||
return json(['code' => 0]);
|
||
}
|
||
|
||
/**
|
||
* 获取问卷详情
|
||
*/
|
||
public function getQuestion() {
|
||
$id = $this->request->post('artrevid');
|
||
$qu_info = $this->article_reviewer_question_obj->where('art_rev_id', $id)->find();
|
||
if ($qu_info) {
|
||
return json(['code' => 0, 'data' => $qu_info]);
|
||
} else {
|
||
return json(['code' => 1]);
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 上传文章的文件
|
||
*/
|
||
public function up_file($type) {
|
||
$file = request()->file($type);
|
||
if ($file) {
|
||
$info = $file->move(ROOT_PATH . 'public' . DS . $type);
|
||
if ($info) {
|
||
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||
} else {
|
||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 存储reviewer文件历史信息
|
||
*/
|
||
private function save_article_reviewer_file($art_rev_id, $user_id, $username, $url, $type_name) {
|
||
//首先确定数据库里面是否存在此数据
|
||
$res = $this->article_reviewer_file_obj->where(['file_url' => $url])->find();
|
||
if ($res) {
|
||
return false;
|
||
}
|
||
$insert_data['art_rev_id'] = $art_rev_id;
|
||
$insert_data['up_user_id'] = $user_id;
|
||
$insert_data['up_username'] = $username;
|
||
$insert_data['file_url'] = $url;
|
||
$insert_data['type_name'] = $type_name;
|
||
$insert_data['ctime'] = time();
|
||
return $this->article_reviewer_file_obj->insert($insert_data);
|
||
}
|
||
|
||
/**
|
||
* 生成pdf感谢reviewer
|
||
*/
|
||
private function pdftest($title) {
|
||
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
||
$pdf->SetHeaderData('logo.png', 25, '', '', array(0, 64, 255), array(0, 64, 128));
|
||
$pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
|
||
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
|
||
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
|
||
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
||
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
|
||
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
|
||
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
|
||
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
|
||
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
|
||
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
|
||
require_once(dirname(__FILE__) . '/lang/eng.php');
|
||
$pdf->setLanguageArray($l);
|
||
}
|
||
$pdf->setFontSubsetting(true);
|
||
$pdf->SetFont('times', '', 14, '', true);
|
||
$pdf->AddPage();
|
||
$pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
|
||
$html ='<div style="margin-top:300px;font-size:16px;"><h3>To whom it may concern</h3>'
|
||
. 'You have reviewed 1 submission in the journal '.$title.' during '.date('Y').'
|
||
Thank you for your support to our journal. This contribution is greatly appreciated.'
|
||
.'<p>Regards<br>
|
||
Editorial Office<br>
|
||
'.$title.'</p>'
|
||
.'<p><h3>Contact us</h3>
|
||
TMR Publishing Group Address: 11 Cockle Bay Rd, Cockle Bay, Auckland 2014, New Zealand<br>
|
||
Telephone: +64 02108293806<br>
|
||
E-mail: publisher@tmrjournals.com</p></div>';
|
||
|
||
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
|
||
// $pdf->Output('example_001.pdf', 'D');
|
||
// $pdf_wj = 'd:/example_001.pdf';
|
||
$pdf_wj = $_SERVER['DOCUMENT_ROOT'].'public/pdf/'.date('YmdHis').'thanks.pdf';
|
||
// $pdf_wj = '/public/pdf/'.date('YMD').'/'.date('His').'thanks.pdf';
|
||
$pdf->Output($pdf_wj, 'F');
|
||
return $pdf_wj;
|
||
}
|
||
|
||
}
|