diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index f5a3c40..a037ece 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -39,6 +39,7 @@ class Article extends Controller { protected $user_reviewer_recommend_obj = ''; protected $email_log_obj = ''; protected $email_template_obj = ''; + protected $production_article_obj = ''; public function __construct(\think\Request $request = null) { parent::__construct($request); @@ -68,6 +69,7 @@ class Article extends Controller { $this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend'); $this->email_log_obj = Db::name('email_log'); $this->email_template_obj = Db::name('email_template'); + $this->production_article_obj = Db::name('production_article'); } /** @@ -132,10 +134,37 @@ class Article extends Controller { ->where('t_article_transfer.state', 2) ->find(); $res[$key]['transinfo'] = $transfer_info; + + + //对于接受的文章查询后续状态 + $proof_state = 0; + if($val['state']==5){ + proofState($val['article_id']); + $p_info = $this->production_article_obj->where('article_id',$val['article_id'])->where('state',0)->find(); + if($p_info&&$p_info['proof_state']==1){ + $proof_state = 1; + } + } + $res[$key]['proof'] = $proof_state; } //返回数据 return json(['total' => $count, 'data' => $res]); + } + + /** + * 获取proof的详情 + */ + public function getProofDetail(){ + $data = $this->request->post(); + $rule = new Validate([]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + + + + } /** diff --git a/application/api/controller/Production.php b/application/api/controller/Production.php index eeadf30..3af55d7 100644 --- a/application/api/controller/Production.php +++ b/application/api/controller/Production.php @@ -924,6 +924,128 @@ class Production extends Controller } } + /** + * 开始proof + */ + public function pushProof(){ + $data = $this->request->post(); + $rule = new Validate([ + 'p_article_id'=>'require' + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $p_info = $this->production_article_obj->where('p_article_id',$data['p_article_id'])->find(); + $article_info = $this->article_obj->where('article_id',$p_info['article_id'])->find(); + $journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find(); + $user_info = $this->user_obj->where('user_id',$article_info['user_id'])->find(); + $this->pdfAddProof($p_info['article_id']); + if($p_info['file_pdf']==''){ + return jsonError('To the editor: PROOF is the final form before the article goes online. The PROOF link step not be opened if you have not completed the previous steps.'); + } + //发送邮件 + $tt = "Dear Author,

"; + $tt .= "Please confirm proof of your manuscript on the submission website within 48 hours. (https://submission.tmrjournals.com)

"; + $tt .= "Click here to confirm the proof.
"; + $tt .= "Click here to make changes based on this version.

"; + $tt .= "If your response is not received, we will regard the author's consent to the version if the time exceeds.

"; + $tt .= "If you have any questions, please feel free to contact us.
"; + $tt .= "Note: Double-check the authors' information carefully to ensure they are correct."; + + + $maidata['email'] = $user_info['email']; + $maidata['title'] = "PROOF|".$journal_info['title']; + $maidata['content'] = $tt; + $maidata['tmail'] = $journal_info['email']; + $maidata['tpassword'] = $journal_info['epassword']; + $file = ROOT_PATH . 'public' . DS.'proofPDF'.DS.$p_info['article_id'].'.pdf'; + sendEmail($maidata['email'],$maidata['title'],$journal_info['title'],$maidata['content'],$maidata['tmail'],$maidata['tpassword'],$file); + // Queue::push('app\api\job\mail@fire', $maidata, "tmail"); + + //更改数据库 + $update['proof_state'] = 1; + $updata['proof_stime'] = time(); + $updata['proof_etime'] = strtotime("+2 day"); + $this->production_article_obj->where('p_article_id',$data['p_article_id'])->update($updata); + + return jsonSuccess([]); + } + + /** + * 自动执行 + */ + public function proofState(){ + $this->production_article_obj->where('proof_state',1)->where('proof_etime','<',time())->update(['proof_state'=>2]); + } + + /** + * 作者反馈proof + */ + public function editProof(){ + $data = $this->request->post(); + $rule = new Validate([ + 'article_id'=>'require', + 'code'=>'require' + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $updata = []; + if($data['code']==0){//同意 + $update['proof_state'] = 2; + }else{//拒绝 + $update['proof_state'] = 2; + $update['proof_content'] = trim($data['content']); + } + //发送邮件提醒编辑 + + + return jsonSuccess([]); + } + + /** + * 同意proof通过邮件链接 + */ + public function editProofFromEmail($articleId){ + $this->production_article_obj->where('article_id',$articleId)->where('state',0)->update(['proof'=>2]); + echo 'Commit Succeeded'; + } + + + private function pdfAddProof($article_id) + { + $p_info = $this->production_article_obj->where('article_id',$article_id)->where('state',0)->find(); + vendor('fpdf.fpdf'); + vendor('fpdi/fpdi'); + $pdf = new \FPDI(); + $pageCount = $pdf->setSourceFile(ROOT_PATH . 'public' . DS.$p_info['file_pdf']); + + // iterate through all pages + for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { + // import a page + $templateId = $pdf->importPage($pageNo); + + // get the size of the imported page + $size = $pdf->getTemplateSize($templateId); + + // create a page (landscape or portrait depending on the imported page size) + if ($size['w'] > $size['h']) $pdf->AddPage('L', array($size['w'], $size['h'])); + else $pdf->AddPage('P', array($size['w'], $size['h'])); + + // use the imported page + // $pdf->useTemplate($templateId); + + $pdf->image(ROOT_PATH . 'public' . DS.'pdf'.DS.'bg2.png',55, 25, 80); + $pdf->image(ROOT_PATH . 'public' . DS.'pdf'.DS.'bg2.png',55, 155, 80); + $pdf->useTemplate($templateId); + // $pdf->SetFont('Arial', 'B', '12'); + // // sign with current date + // $pdf->SetXY(0, 0); // you should keep testing untill you find out correct x,y values + // $pdf->Write(7, date('Y-m-d')); + } + $pdf->Output(ROOT_PATH . 'public' . DS.'proofPDF'.DS.$article_id.'.pdf'); + } + /** * @title 文章文件上传 * diff --git a/application/api/controller/Typeset.php b/application/api/controller/Typeset.php index 7393951..eb1ed1f 100644 --- a/application/api/controller/Typeset.php +++ b/application/api/controller/Typeset.php @@ -538,7 +538,7 @@ class Typeset extends Controller /** * pdf文件加水印 */ - public function pdfAddPfroof() + public function pdfAddProof() { vendor('fpdf.fpdf'); vendor('fpdi/fpdi'); diff --git a/application/common.php b/application/common.php index 208e4a2..e145a0d 100644 --- a/application/common.php +++ b/application/common.php @@ -127,6 +127,12 @@ function get_str(){ } + +function proofState($article_id){ + $p_article_obj = Db::name('production_article'); + $p_article_obj->where('article_id',$article_id)->where('state','<>',1)->where('proof_etime','<',time())->where('proof_state',1)->update(['proof_state'=>2]); +} + /** * 生成文章sn号 * @return type