From 633d37b2882a723d2ff56b4c2acc1efd218f9a38 Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Fri, 20 May 2022 12:14:32 +0800 Subject: [PATCH] edit-down_img_size --- admin/controllers/Img.php | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/admin/controllers/Img.php b/admin/controllers/Img.php index c0a4e456..beb1f739 100644 --- a/admin/controllers/Img.php +++ b/admin/controllers/Img.php @@ -37,12 +37,15 @@ class Img extends CI_Controller require_once COMMPATH.'/third_party/TCPDF/tcpdf.php'; $brand_id = $this->input->get('brand_id'); $page = $this->input->get('page'); + $size = $this->input->get('size'); !$page && $page = 1; + !$size && $size = 5; $params = [ 'status_pid' => 0, 'status' => 1, 'brand_id' => $brand_id, - 'page' => $page + 'page' => $page, + 'size' => $size ]; $result = $this->ordersv2list->lists($params['status_pid'], $params); $lists = $result['lists']; @@ -55,6 +58,21 @@ class Img extends CI_Controller $contract = $this->order_contracts_model->select(['o_id'=>$val['o_id'],"imgs <> ''"],'','','','id,o_id,file,imgs,type'); if($contract){ foreach ($contract as $v) { + $path = FCPATH."pdf/{$row['sid']}"; + if (!file_exists($path)) { + $oldumask = umask(0); + mkdir($path, 0777, true); + umask($oldumask); + } + if($val['o_id']>=10000){ + $file_name = $type_arr[$v['type']] ? $type_arr[$v['type']].'.pdf' : '其它_'.time().'.pdf'; + }else{ + $file_name = $old_type_arr[$v['type']] ? $old_type_arr[$v['type']].'.pdf' : '其它_'.time().'.pdf'; + } + if(file_exists($path.'/'.$file_name)){ + echo "合同id:{$v['id']},已生成
"; + continue; + } $imgs = json_decode($v['imgs'],true); if(is_array($imgs)){ $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT,true, 'UTF-8', false); @@ -81,17 +99,7 @@ class Img extends CI_Controller $pdf->Ln(); $pdf->Image('@'.$res, '', '', '', '', '', $img_url,'' , false, 300, '', false, false, 0.05, false, false, false); } - $path = FCPATH."pdf/{$row['sid']}"; - if (!file_exists($path)) { - $oldumask = umask(0); - mkdir($path, 0777, true); - umask($oldumask); - } - if($val['o_id']>=10000){ - $file_name = $type_arr[$v['type']] ? $type_arr[$v['type']].'.pdf' : '其它_'.time().'.pdf'; - }else{ - $file_name = $old_type_arr[$v['type']] ? $old_type_arr[$v['type']].'.pdf' : '其它_'.time().'.pdf'; - } + $pdf->Output( $path.'/'.$file_name,'F'); echo "合同id:{$v['id']},保存成功{$path}/{$file_name}
"; }else{